diff options
Diffstat (limited to 'l10ntools/java/l10nconv/java/com/sun')
26 files changed, 0 insertions, 6346 deletions
diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/DirtyTags/DirtyTagWrapCheck.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/DirtyTags/DirtyTagWrapCheck.java deleted file mode 100755 index 7338e8d6a669..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/DirtyTags/DirtyTagWrapCheck.java +++ /dev/null @@ -1,82 +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. - * - ************************************************************************/ -/* - * Created on 2005 - * by Christian Schmidt - */ -package com.sun.star.tooling.DirtyTags; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; - - - -public class DirtyTagWrapCheck { - static String line=""; - public static void main(String[] args) { - try { - File fi = new File("D:\\Testfiles\\KID_helpcontent.sdf");//Copy of - FileReader fr = new FileReader(fi); - BufferedReader br = new BufferedReader(fr); - - int readCounter=0; - int missCounter=0; - int lineErrorCounter=0; - while((line=br.readLine())!=null){ - readCounter++; - String [] split = line.split("\t"); - if(split.length<15){ - - lineErrorCounter++; - continue; - } - String string = split[10]; - String wrapped = DirtyTagWrapper.wrapString(string); - String unwrapped=DirtyTagWrapper.unwrapString(wrapped); - if(!string.equals(unwrapped)){ - - missCounter++; - System.out.println(""+readCounter+"\n"+string+"\n"+unwrapped+"\n"+wrapped+"\n"); - } - } - System.out.println("Fertig "+readCounter+" "+missCounter+" "+lineErrorCounter); - } catch (FileNotFoundException e) { - // - e.printStackTrace(); - } catch (IOException e) { - // - e.printStackTrace(); - } catch (DirtyTagWrapper.TagWrapperException e) { - System.out.println(e.getMessage()+"\n"+line+"\n"); - - } - - } -} diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/DirtyTags/DirtyTagWrapper.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/DirtyTags/DirtyTagWrapper.java deleted file mode 100755 index 6b76b75b75d6..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/DirtyTags/DirtyTagWrapper.java +++ /dev/null @@ -1,249 +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. - * - ************************************************************************/ -/* - * Created on 2005 - * by Christian Schmidt - */ -package com.sun.star.tooling.DirtyTags; - -import java.io.IOException; -import java.util.ArrayList; - -/** - * Solves the problem with translating strings from the - * Star-Office Help. This Strings contain XML snippets - * (that means parts of an xml dokument). I call them 'dirty' - * because the start of a tag (<) and the and of an tag (>) - * are quoted by a single backslash(\<.....\>). This is done - * because the text out of th tags should not contain '<' and '>' - * as Entity references (< or >) but as readable signs. - * This is for translation purposes. - * Because translators get mad while find out the really translatable - * parts between all the markup information, the XLIFF Specification - * allows to wrap parts of a String that should not be translated by - * special tags (<ept>, <bpt>). - * This Class has two static methods that do the wrapping and unwrapping - * NOTE: this won't work with not 'dirty' Strings. - * - * @author Christian Schmidt 2005 - * - */ -public class DirtyTagWrapper { - - private static boolean doWrap=true; - public static void setWrapping(boolean doWrap){ - DirtyTagWrapper.doWrap=doWrap; - } - - /** - * Unwraps the 'dirty' parts of a String from ept and bpt tags - * - * @param checkString The String to unwrap - * @return the unwrapped String - */ - public static String unwrapString(String checkString){ - //remove the ept and bpt tags - String[] splitted =checkString.split("(<ept ([^<>])*>)|(</ept>)|(<bpt ([^<>])*>)|(</bpt>)|(<sub([^<>])*>)|(</sub>)|(<ex ([^<>])*/>)"); - StringBuffer workBuffer= new StringBuffer(); - for(int i=0;i<splitted.length;i++){ - workBuffer.append(splitted[i]); - } - String string = new String(workBuffer); - //replace Entity references - string=string.replaceAll( "&","&").replaceAll( "<","<").replaceAll( ">",">").replaceAll( ""","\"").replaceAll( "'","'"); - - //remove the nsub tags - splitted =string.split("(<sub([^<>])*>)|(</sub>)"); - StringBuffer returnBuffer= new StringBuffer(); - for(int i=0;i<splitted.length;i++){ - returnBuffer.append(splitted[i]); - } - String returnString = new String(returnBuffer); - return returnString; - } - - - /** - * Wrap the dirty parts of a string - * - * @param checkString The String to check if there are dirty Parts to wrap - * @return A String with wrapped dirty parts - * @throws TagWrapperException - * @throws IOException - */ - public static String wrapString(String checkString) throws TagWrapperException, IOException { - // if no wrapping should be done return the given string - if(!doWrap) return checkString; - // let's wrap - String[] parts=null; - int idx=0; - //split the string at tag ends - String[] parts2 = checkString.split("\\\\>"); - - ArrayList tagString =new ArrayList(); - // put the while splitting lost parts to the end of the single strings - for(int j=0;j<parts2.length-1;j++){ - parts2[j]+="\\>"; - } - // same for the last string - if (checkString.endsWith("\\>")){ - parts2[parts2.length-1]+="\\>"; - } - // split the leading text from the real tag string (<...>) - for(int j=0;j<parts2.length;j++){ - - //is it just a tag - if(parts2[j].startsWith("\\<")){ - tagString.add(parts2[j]); - // or is it a tag with leading text? - }else if((idx=parts2[j].indexOf("\\<"))>0&&parts2[j].indexOf("\\>")>0){ - //...then split it in two parts - // the leading text - tagString.add(parts2[j].substring(0,(parts2[j].indexOf("\\<")))); - // ...and the tag - tagString.add(parts2[j].substring(parts2[j].indexOf("\\<"))); - - }else{ - //no tag...must be text only - tagString.add(parts2[j]); - } - - } - ArrayList tagNames=new ArrayList(); - String item=""; - for(int i=0;i<tagString.size();i++){ - item=((String)tagString.get(i)); - int start=item.indexOf("\\<")+2; - // check if we have an index that is ok - if(start==1) start=-1; - int end=item.lastIndexOf("\\>"); - if(start>=0&&end>0){ - boolean isStandalone=false; - if(item.endsWith("/\\>")){ - // this is a standalone tag - isStandalone=true; - } - item=item.substring(start,end); - - if(item.indexOf(" ")>0){ - item=item.substring(0,item.indexOf(" ")); - } - if(isStandalone){ - item=item+"/"; - } - tagNames.add(item); - }else{ - tagNames.add(""); - } - } - ArrayList tagType=new ArrayList(); - for(int i=0;i<tagNames.size();i++){ - if(((String)tagNames.get(i)).equals("")){ - tagType.add("Text"); - }else if(((String)tagNames.get(i)).startsWith("/")){ - tagType.add("EndTag"); - }else if(((String)tagNames.get(i)).endsWith("/")){ - tagType.add("StartAndEndTag"); - }else { - tagType.add("StartTag"); - } - - } - - ArrayList tagList=new ArrayList(); - for(int i=0;i<tagNames.size();i++){ - tagList.add(new Tag( - (String)tagType.get(i), - (String)tagNames.get(i), - (String)tagString.get(i))); - } - tagType=null; - tagNames=null; - tagString=null; - - TagPair start; - StringBuffer returnBuffer=new StringBuffer(); - while(tagList.size()>0){ - try{ - start=new TagPair(tagList); - returnBuffer.append(start.getWrapped()); - }catch(TagPair.TagPairConstructionException e){ - throw (new DirtyTagWrapper()).new TagWrapperException(e); - } - } - TagPair.resetCounter(); - return new String(returnBuffer); - } - /** - * @author Christian Schmidt 2005 - * - */ - public class TagWrapperException extends Exception { - - /** - * Create a new Instance of TagWrapperException - * - * - */ - public TagWrapperException() { - super(); - // - } - - /** - * Create a new Instance of TagWrapperException - * - * @param arg0 - */ - public TagWrapperException(String arg0) { - super(arg0); - // - } - - /** - * Create a new Instance of TagWrapperException - * - * @param arg0 - * @param arg1 - */ - public TagWrapperException(String arg0, Throwable arg1) { - super(arg0, arg1); - // - } - - /** - * Create a new Instance of TagWrapperException - * - * @param arg0 - */ - public TagWrapperException(Throwable arg0) { - super(arg0); - // - } - - } -} diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/DirtyTags/Tag.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/DirtyTags/Tag.java deleted file mode 100755 index 223885571007..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/DirtyTags/Tag.java +++ /dev/null @@ -1,246 +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. - * - ************************************************************************/ -/* - * Created on 2005 - * by Christian Schmidt - */ -package com.sun.star.tooling.DirtyTags; - -import java.io.IOException; -import java.util.Map; - -import com.sun.star.tooling.converter.ExtMap; - -/** - * @author Christian Schmidt 2005 - * - */ -public class Tag { - private static int indent=0; - Map tagNames; - private String tagType; - private String tagName; - private String tagString; - public static Tag EMPTYTAG=new Tag("","",""); - - /** - * Create a new Instance of Tag - * - * @param tagType - * @param tagName - * @param tagString - */ - public Tag(String tagType, String tagName, String tagString) { - - this.tagType=tagType; - this.tagName=tagName; - this.tagString=tagString; - - tagNames=new ExtMap(); - tagNames.put("link","name"); - tagNames.put("caption","xml-lang"); - tagNames.put("alt","xml-lang"); - } - - public String getWrappedTagString() throws IOException{ - if(this.canHaveTranslateableContent()){ - return this.wrapTagStringIntern(); - }else{ - return xmlString(this.tagString); - } - } - - private final String xmlString( final String string) throws java.io.IOException { - if (string == null) - return string; // "" - String str = string; - - for(int i=0;i<str.length();i++){ - if(str.charAt(i)=='&'){ - str=str.substring(0, i)+"&"+str.substring(i+1); - continue; - } - - if(str.charAt(i)=='<'){ - str=str.substring(0, i)+"<"+str.substring(i+1); - continue; - } - - if(str.charAt(i)=='>'){ - str=str.substring(0, i)+">"+str.substring(i+1); - continue; - } - - if(str.charAt(i)=='"'){ - str=str.substring(0, i)+"""+str.substring(i+1); - continue; - } - - if(str.charAt(i)=='\''){ - str=str.substring(0, i)+"'"+str.substring(i+1); - continue; - } - } - - return str; - } - /** - * @return - */ - private boolean canHaveTranslateableContent() { - return (tagNames.containsKey(this.tagName)); - - } - - /** - * @throws IOException - * - */ - private String wrapTagStringIntern() throws IOException { - - - String[] split=this.tagString.split("="); - int length=split.length; - // no attribute found; - if (length==0) return xmlString(tagString); - else{ - int i=0; - - while(i<length-1/*the last part can only contain an attribute value*/){ - String attributeName = split[i].trim(); - if(split[i]. indexOf("</sub>")<0) split[i]=xmlString(split[i]); - i++; - String value; - attributeName=(attributeName.substring(attributeName.lastIndexOf(" ")).trim()); - if((value=translateableAttributeValue(this.tagName)).equals(attributeName)){ - int valueStart=0; - int valueEnd=0; - - // get the value to the found attribute name - // it must either be surrounded by '"'... - if((valueStart=split[i].indexOf('"'))>=0){ - valueEnd = split[i].lastIndexOf('"'); - //...or surrounded by "'" - }else if((valueStart=split[i].indexOf("'"))>=0){ - valueEnd = split[i].lastIndexOf("'"); - }else{ - // there seems to be an error, - // we found an '=' (we split there) but no '"' or ''' - // but although we don't check the syntax - // we just continue - continue; - } - //ok we found the border of a value that might be translated - //now we wrap it with the tags - - split[i]=xmlString(split[i].substring(0,valueStart+1))+"<sub>"+xmlString(split[i].substring(valueStart+1,valueEnd))+"</sub>"+xmlString(split[i].substring(valueEnd)); - - } - } - String wrappedString=""; - // we have the wrapped parts, now we put them together - int j=0; - for(j=0;j<split.length-1;j++){ - wrappedString+=(split[j]+"="); - } - wrappedString+=split[j]; -// System.out.println(this.tagString); -// System.out.println(wrappedString); - return wrappedString; - } - - } - - - - /** - * @param tagName the name of the tag to check - * @return the name of the attribute that can contain translateable value - */ - private String translateableAttributeValue(String tagName) { - - return (String)this.tagNames.get(tagName); - } - - - /** - * Create a new Instance of Tag - * - * - */ - public Tag(String tagString) { - this(extractTagType(extractTagName(tagString)),extractTagName(tagString),tagString); - } - - private static String extractTagName(String tagString){ - - int start=tagString.indexOf('<')+1; - int end=tagString.lastIndexOf('\\'); - if(start>=0&&end>0){ - tagString=tagString.substring(start,end); - - if(tagString.indexOf(" ")>0){ - tagString=tagString.substring(0,tagString.indexOf(" ")); - } - return tagString; - }else{ - return ""; - } - } - private static String extractTagType(String tagName){ - if(tagName.equals("")){ - return "Text"; - }else if(tagName.startsWith("/")){ - return "EndTag"; - }else if(tagName.endsWith("/")){ - return "StartAndEndTag"; - }else { - return "StartTag"; - } - } - - /** - * @return Returns the tagName. - */ - public String getTagName() { - return this.tagName; - } - /** - * @return Returns the tagString. - */ - public String getTagString() { - return this.tagString; - } - /** - * @return Returns the tagType. - */ - public String getTagType() { - return this.tagType; - } - - -} diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/DirtyTags/TagPair.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/DirtyTags/TagPair.java deleted file mode 100755 index cc362a96e740..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/DirtyTags/TagPair.java +++ /dev/null @@ -1,307 +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. - * - ************************************************************************/ -/* - * Created on 2005 - * by Christian Schmidt - */ -package com.sun.star.tooling.DirtyTags; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; - - -/** - * @author Christian Schmidt 2005 - * - */ -public class TagPair { - - - private Tag startTag=Tag.EMPTYTAG; - private Tag endTag=Tag.EMPTYTAG; - private String startingText=""; - private ArrayList enclosedTags=new ArrayList(); - private long id; - private static int ElementCounter=1; - private String endingText=""; - - /** - * @author Christian Schmidt 2005 - * - */ - public class TagPairConstructionException extends Exception { - - /** - * Create a new Instance of TagPairConstructionException - * - * @param string - */ - public TagPairConstructionException(String string) { - - } - - } - - /** - * Create a new Instance of TagPair - * - * - */ - public TagPair() { - - } - - - /** - * Create a new Instance of TagPair - * - * Find matching tags in tagList, create a TagPair of it, create - * tagPairs from the content in the tagPair and remove all used - * tags from tagList. The rest of the tagList starts after the - * endTag of this TagPair. - * - * @param tagList a List of the tags to check - * - * @throws TagPairConstructionException - */ - public TagPair(ArrayList tagList) throws TagPairConstructionException { - - if(tagList.size()==0){ - return; - } - ArrayList contentList=new ArrayList();; - Tag tag=(Tag)tagList.get(0); - tagList.remove(0); - - - if("Text".equals(tag.getTagType())){ - // is this Text the only content - // of this Tag ? - if(tagList.size()==0){ - //yes...then it is the starting Text of this TagPair - this.startingText=tag.getTagString(); - return; - }else{ - //no...the tag is normal content - contentList.add(tag); - } - this.startingText=tag.getTagString(); - - }else if("EndTag".equals(tag.getTagType())){ - //ERRor throw EXception - }else if("StartTag".equals(tag.getTagType())){ - // find the matching end tag - this.startTag=tag; - Iterator iter=tagList.iterator(); - - int equivalentTagCounter=0; - while(iter.hasNext()){ - //is this the end tag? - if((tag=(Tag)iter.next()).getTagName().equals('/'+this.startTag.getTagName())&&equivalentTagCounter==0){ - //found the corresponding end tag - - //this TagPair is complete - //so it needs an id - this.id=TagPair.ElementCounter++; - this.endTag=tag; - //...remove it from list - tagList.removeAll(contentList); - tagList.remove(tag); - break; - }else{ - // tag is not the end tag - // so it is between the start and the end tag - // and belongs to the content - // but first check if it has the same name as the current tag - if(tag.getTagName().equals(this.startTag.getTagName())){ - // if this is a start tag like the current start tag - // we count it to find out the matching end tag in nested tags - if(tag.getTagType().equals("StartTag")){ - equivalentTagCounter++; - } - } - if(tag.getTagName().equals("/"+this.startTag.getTagName())){ - if(tag.getTagType().equals("EndTag")){ - equivalentTagCounter--; - } - } - - contentList.add(tag); - } - } - //found the end tag ? - //no... - if (this.endTag.getTagType()==""){ - - throw new TagPairConstructionException("ERROR: Missing end tag ("+ - this.startTag.getTagString()+")."); - //...yes - }else{ - //We need to check whether the content is starting or ending with text - //...check starting with text - if(contentList.size()>=1&&((String)((Tag)contentList.get(0)).getTagType()).equals("Text")){ - //yes...store it as startingText - this.startingText=(String)((Tag)contentList.get(0)).getTagString(); - //remove it from list - contentList.remove(0); - } - // ...check ending with text - if(contentList.size()>=1&&((String)((Tag)contentList.get(contentList.size()-1)).getTagType()).equals("Text")){ - //yes...store it as endingText - this.endingText=(String)((Tag)contentList.get(contentList.size()-1)).getTagString(); - //remove it from list - contentList.remove(contentList.size()-1); - } - //create the list of tags enclosed by this tagPair - createEnclosedTags(contentList); - } - //if stand AloneTag create own TagObject...give ID...add to List - }else if("StartAndEndTag".equals(tag.getTagType())){ - this.startTag=tag; - this.endTag=new Tag("EndOfStandAlone","",""); - createEnclosedTags(contentList); - } - - } - - /** - * @param contentList - * @throws TagPairConstructionException - */ - private void createEnclosedTags(ArrayList contentList) throws TagPairConstructionException { - while(contentList.size()>0){ - //create the inner TagPairs - this.enclosedTags.add(new TagPair(contentList)); - } - - } - - public String toString(){ - StringBuffer outString= new StringBuffer(this.startTag.toString()); - TagPair help=new TagPair(); - Iterator iter=enclosedTags.iterator(); - outString.append(this.startingText); - while(iter.hasNext()){ - if((help=(TagPair)iter.next())==null){ - continue; - }else{ - outString.append(help.toString()); - } - } - outString.append(this.endingText); - outString.append(this.endTag.toString()); - return new String(outString); - } - - public String getWrapped() throws IOException{ - Iterator iter=enclosedTags.iterator(); - StringBuffer returnBuffer=new StringBuffer(); - - returnBuffer.append(wrap(this.startTag)+xmlString(this.startingText)); - while(iter.hasNext()){ - returnBuffer.append(((TagPair)iter.next()).getWrapped()); - } - returnBuffer.append(xmlString(this.endingText)+wrap(this.endTag)); - - - - return new String(returnBuffer); - } - - private String wrap(Tag tag) throws IOException{ - String string=""; - //can be a start tag - if(tag.getTagType().startsWith("Start")){ - return new String("<bpt id='"+this.id+"'>"+tag.getWrappedTagString()+"</bpt>"); - //...or a end tag - }else if (tag.getTagType().startsWith("End")){ - //maybe the end tag of a Start and end tag -// if("EndOfStandAlone".equals(tag.getTagType())){ -// return new String("<ex id='"+this.id+"'/>"); -// }else{ - string=tag.getWrappedTagString(); - return new String("<ept id='"+this.id+"'>"+string+"</ept>"); -// } - - //...or text - }else{ - return xmlString(tag.getTagString()); - } - } - /** - * Replaces all characters that mustn't be in XLIFF PCdata - * - * @param string the string to check - * @return the checked string with all characters replaced - * @throws java.io.IOException - */ - private final String xmlString( final String string) throws java.io.IOException { - if (string == null) - return string; // "" - String str = string; - - for(int i=0;i<str.length();i++){ - if(str.charAt(i)=='&'){ - str=str.substring(0, i)+"&"+str.substring(i+1); - continue; - } - - if(str.charAt(i)=='<'){ - str=str.substring(0, i)+"<"+str.substring(i+1); - continue; - } - - if(str.charAt(i)=='>'){ - str=str.substring(0, i)+">"+str.substring(i+1); - continue; - } - - if(str.charAt(i)=='"'){ - str=str.substring(0, i)+"""+str.substring(i+1); - continue; - } - - if(str.charAt(i)=='\''){ - str=str.substring(0, i)+"'"+str.substring(i+1); - continue; - } - } - - return str; - } - - /** - * - */ - public static void resetCounter() { - TagPair.ElementCounter=1; - - } - - -} diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/Convert.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/Convert.java deleted file mode 100755 index d6fddfd049ae..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/Convert.java +++ /dev/null @@ -1,550 +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. - * - ************************************************************************/ -/* - * the main Class - * - * Command Line arguments are reviewed - * and a Converter is constructed - */ -package com.sun.star.tooling.converter; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.Calendar; - -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 - * <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 - */ - private static final char extensionSeperator = '.'; - - /** - * the log File - */ - private static File log; - - /** - * the name of the log file - */ - private static String logString = EMPTY; - - /** - * indicates whether existing sources should be overwritten - * without asking - */ - private static boolean overwrite = false; - - /** - * A second Source File needed for GSI Merging - */ - private static File secondSource; - - //private static final char pathSeperator = '\\'; - - /** - * The language that should be the source language - * that means the language to translate from - */ - private static String sourceLanguage = "en-US"; - - /** - * the name of the source file - */ - private static String sourceName = EMPTY; - - /** - * the type of the source file (sdf,xliff,...) - */ - private static String sourceType = EMPTY; - - /** - * The time when converting started - */ - private static String startTime = EMPTY; - /** - * The language that should be the target language - * that means the language to translate to - */ - private static String TargetLanguage = EMPTY; - - /** - * the name of the target file - */ - private static String targetName = EMPTY; - - /** - * the type of the target file (sdf,xliff,...) - */ - private static String targetType = EMPTY; - - /** - * Store the current version ID and number of this tool - */ - final static String version = " Prod.20050710:1255 "; - - /** - * The name of the (original) sdf file used as second source for gsi->sdf merging - */ - private static String secondSourceName=EMPTY; - /** - * Indicate whether strings in xliff files should - * 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 - ParameterChecker.checkClParameters(args); - ParameterChecker.createContentOfClParameters(); - //Initialize the tagWrapper - DirtyTagWrapper.setWrapping(doWrap); - //create an instance of converter - Converter conv = new Converter(sourceType, sourceName, sourceLanguage, - targetType, targetName, TargetLanguage,secondSourceName, overwrite); - // get aktual 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 occured, please check your commad line settings \n"+e.getMessage()); - System.exit(-1); - }catch(Throwable t){ - System.out.print("A FATAL ERROR occured, please check your commad line settings \n"+t.getMessage()); - System.exit(-1); - } - - } - - /** - * show the command line help - */ - private static void printHelp() { - - final String ls = System.getProperty("line.separator"); - System.out - .println( - - "File Converting Tool 'converter' Version " - + Convert.version - + ls - + "Converts SDF files to wellformed XLIFF or GSI files and vice versa" + ls - + ls - + "Use: " + ls - + "convert [-h]|[SourcePath [TargetPath] [-T Type] [[-S Type [secondSourcePath]] " + ls - + " [-s LanguageID] [-t LanguageID] [-l [LogPath]] [-o]]" + ls - + ls - + "-h show this help." + ls - + "SourcePath path of the file to convert." + ls - + "secondSourcePath path of the SDF file to merge to (GSI -> SDF only!)." + ls - + "TargetPath path where to store the result." + ls - + "LogPath path of the log file" + ls - + "-T Type the type of the target file (xliff,sdf,gsi)" + ls - + "-S Type the type of the source file (xliff,sdf,gsi)" + ls - + "-s LanguageID the ISO language code of the source language (de, fr...)." + ls - + " 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 - + "-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 - + "for the logfile." + ls); - } - - /** - * show the parameters the converter starts with - * - * @throws IOException - */ - final private static void printPreamble() throws IOException { - OutputHandler.out(EMPTY); - OutputHandler.out("Source File is: " + sourceName); - OutputHandler.out("Target File is: " + targetName); - if (OutputHandler.doLog) { - OutputHandler.out("Log File is: " + logString); - } else { - OutputHandler.out("Log File is: disabled"); - } - - OutputHandler.out(EMPTY); - - } - - /** - * show some statistic data - * - * @throws IOException - */ - final private static void showStatistic() throws IOException { - OutputHandler.dbg(EMPTY); - OutputHandler - .out((targetType.equalsIgnoreCase("xliff") ? "TransUnits written: " - : "Lines written : ") - + Converter.getLineCounter()); - OutputHandler.dbg(EMPTY); - OutputHandler.out("Started at : " + Convert.startTime); - Convert.cal = Calendar.getInstance(); - OutputHandler.out("Finished at : " + Convert.cal.getTime()); - OutputHandler.dbg(EMPTY); - - } - - /** - * Get the extensiion of a file name - * (sdf,xliff,gsi) - * - * @param sourceString the file name - * @return the extension - */ - static protected String extractExtension(String sourceString) { - String ext = sourceString.substring(sourceString - .lastIndexOf(Convert.extensionSeperator) + 1); - return ext; - } - -// static protected String extractFileName(String sourceString) { -// String sName = EMPTY; -// sName = (sourceString.substring(sourceString -// .lastIndexOf(File.separator) + 1, sourceString -// .lastIndexOf(Convert.extensionSeperator))); -// -// return sName; -// } -// -// static protected String extractPath(String sourceString) { -// String sPath = sourceString.substring(0, sourceString -// .lastIndexOf(File.separator) + 1); -// return sPath; -// } - - /** - * - */ - public Convert() { - } - - /** - * - * Verify a parameter array and create content useable by the programm - * from the switches and attributes set at command line - * - * @author Christian Schmidt 2005 - */ - private static class ParameterChecker { - - /** - * Holds the path of the source file - */ - private static String filePath; - /** - * Holds the name of the source file - */ - private static String fileName; - - /** - * 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... - if (args.length == 0) { - printHelp(); - System.exit(-1); - } - //...or attribute is -h - if (args[0].equals("-h")) { - printHelp(); - System.exit(0); - } - if (args[0].equals("-ver")) { - System.out.println("File Converting Tool Version "+version); - System.exit(0); - } - //source file Location and path is always first attribute - sourceName = new String(args[0]); - - 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 '" - + 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 - && (!args[i + 1].startsWith("-"))) { - logString = args[++i]; - } else { - logString = EMPTY; - } - 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]; - } else { - throw new ConverterException( - "missing argument for -t target language"); - } - continue; - } - - if (i == 1 && !args[i].startsWith("-")) { //target file - // found - targetName = args[i]; - continue; - } - //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 occured while parsing the command line,\n please check your commad line settings.\n "+t.getMessage()); - System.exit(-1); - } - - }//end checkClParameters - - /** - * Creates the appropriate content of what ever data - * we found in the command line - * - * @throws IOException - */ - private static void createContentOfClParameters() throws IOException { - - try { - if (OutputHandler.doDebug) { - // if the -dbg switch is set, we - // create - // a file that gets all information - // produced by this tool - - OutputHandler.dbgFile = new BufferedWriter(new FileWriter( - new File(new String(filePath + fileName + ".dbg")))); - } - - if (OutputHandler.doLog) {// create a logfile? - //given at command line? - if (EMPTY.equals(logString) || logString == null) { - logString = new String(filePath + fileName + ".log"); - } - log = FileMaker.newFile(logString, overwrite); - OutputHandler.logFile = (new BufferedWriter(new FileWriter( - log))); - } - - if (EMPTY.equals(sourceType) || sourceType == null) { - // not given at command line? - if (!(EMPTY.equals(sourceName) || sourceName == null)) { - sourceType = extractExtension(sourceName); - } else { - 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? - if (EMPTY.equals(targetType) || targetType == null) { - if (!(EMPTY.equals(targetName) || targetName == null)) { - targetType = extractExtension(targetName); - } else { - throw new ConverterException("Target type is missing"); - - } - } - //no target File specified at command line - if (EMPTY.equals(targetName) || targetName == null) { - targetName = filePath + fileName + "." + targetType; - if (targetName.equals(Convert.secondSourceName)){ - OutputHandler.out("ERROR: \nSource '"+Convert.secondSourceName+"' and \nTarget'"+targetName+"' are the same"); - System.exit(0); - }else if (targetName.equals(Convert.sourceName)){ - OutputHandler.out("ERROR: \nSource '"+Convert.sourceName+"' and \nTarget'"+targetName+"' are the same"); - System.exit(0); - } - }else if (targetName.equals(Convert.secondSourceName)){ - OutputHandler.out("ERROR: \nSource '"+Convert.secondSourceName+"' and \nTarget'"+targetName+"' are the same"); - System.exit(0); - }else if (targetName.equals(Convert.sourceName)){ - OutputHandler.out("ERROR: \nSource '"+Convert.sourceName+"' and \nTarget'"+targetName+"' are the same"); - System.exit(0); - } - - - } catch (ConverterException e) { - OutputHandler.out(e.getMessage()); - } - - } - - } - -}
\ No newline at end of file diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/Converter.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/Converter.java deleted file mode 100755 index ad846ae88295..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/Converter.java +++ /dev/null @@ -1,520 +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. - * - ************************************************************************/ -/* - * Converter.java - * - * create Source and Target - * for converting - * TODO maybe a factory would be good here - */ - -package com.sun.star.tooling.converter; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.xml.sax.EntityResolver; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; -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 - */ -public final class Converter { - - /** - * the used charset f.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 - */ - private static DataHandler handler; - - /** - * Counting the lines written by a writer - */ - private static int lineCounter; - - /** - * The target to write to - */ - private static DataWriter theTargetWriter; - - - /** - * Overwrite existing files - */ - private boolean overwrite = false; - /** - * The source to read from - */ - private Source reader; - /** - * The name of the source file - */ - private String sourceString; - /** - * the Type of the Source file(SDF,GSI,XLIFF) - */ - private String sourceType; - /** - * The name of the target fille - */ - private String targetString; - /** - * the Type of the Target file(SDF,GSI,XLIFF) - */ - private String targetType; - /** - * The writer that handles the output - */ - private Target writer; - - /** - * The sourceLanguage - */ - String sourceLanguage = "en-US"; - - /** - * The targetLanguage - */ - String targetLanguage = ""; - - /** - * The name of the second source, needed for GSI to SDF merge - */ - private String secondSourceString=EMPTY; - - - /** - * Get the line counter - * @return Returns the lineCounter. - */ - public static int getLineCounter() { - return lineCounter; - } - - /** - * increment the lineCounter - */ - final static void countLine() { - lineCounter++; - } - - /** - * 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 - * @param targetType the type of the targetFile - * @param targetString the name of the targetFile - * @param TargetLanguage the ISO Id of the targetLanguage - * @param secondSourceString the name of the second sourceFile (GSI merge only) - * @param overwrite indicates whether overwrite existing files - * @throws IOException - * @throws Exception - */ - public Converter(String sourceType, String sourceString, - String SourceLanguage, String targetType, String targetString, - String TargetLanguage,String secondSourceString, boolean overwrite) throws IOException, - Exception { - - this.sourceType = sourceType; - this.sourceString = sourceString; - this.sourceLanguage = SourceLanguage; - this.targetType = targetType; - this.targetString = targetString; - this.targetLanguage = TargetLanguage; - this.secondSourceString=secondSourceString; - this.overwrite = overwrite; - - handler = new DataHandler(); - - if ("sdf".equalsIgnoreCase(sourceType)) { - reader = new SDFSource(); - } else if ("xliff".equalsIgnoreCase(sourceType)||"dbxliff".equalsIgnoreCase(sourceType)) { - reader = new XLIFFSource(); - } else if ("gsi".equalsIgnoreCase(sourceType)) { - reader = new GSISource(); - } else { - throw new ConverterException("Unknown Source File Type: '"+sourceType+"'"); - } - - if ("sdf".equalsIgnoreCase(targetType)) { - writer = new SDFTarget(); - } else if ("xliff".equalsIgnoreCase(targetType)) { - writer = new XLIFFTarget(); - } else if ("gsi".equalsIgnoreCase(targetType)) { - writer = new GSITarget(); - } else { - throw new ConverterException("Unknown Target File Type: '"+targetType+"'"); - } - - } - - /** - * Do the converting from the source file format to the target file format - * - * @throws IOException - */ - public final void convert() throws IOException { - - try { - - reader.convertTo(writer); - - //TODO this belongs in the Target Class - theTargetWriter.flush(); - theTargetWriter.close(); - } catch (Exception e) { - OutputHandler.out(e.getMessage()); - } - - } - - - /** - * - * Encapsulate the reading from an GSI file - * - * @author Christian Schmidt 2005 - * - */ - private class GSISource implements Source { - DataReader theSourceReader; - /** - * Create a new Instance of GSISource - * - * @throws IOException - * @throws Exception - */ - public GSISource() throws IOException { - - theSourceReader = new GSIandSDFMerger(new File(sourceString),new File(secondSourceString), sourceLanguage, - targetLanguage, CHARSET); - } - - public void convertTo(Target t) { - - try { - theTargetWriter = t.getWriter(); - while (handler.fillDataFrom(theSourceReader)) { - - theTargetWriter.getDatafrom(handler); - theTargetWriter.writeData(); - } - } catch (IOException e) { - OutputHandler.out(e.getMessage()); - - } catch (Exception e) { - e.printStackTrace(); - } - - } - - } - /** - * - * 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 - */ - public GSITarget() throws FileNotFoundException, IOException { - - target = FileMaker.newFile(targetString, overwrite); - theTargetWriter = new GSIWriter(new BufferedOutputStream( - new FileOutputStream(target)), CHARSET); - } - - public DataWriter getWriter() { - - return theTargetWriter; - } - - } - /** - * - * Encapsulate the reading from an SDF file - * - * @author Christian Schmidt 2005 - * - */ - private final class SDFSource implements Source { - - DataReader Source; - - /** - * Create a new Instance of SDFSource - * @throws IOException - * @throws Exception - */ - public SDFSource() throws IOException, Exception { - - Source = new SDFReader(new File(sourceString), sourceLanguage, - targetLanguage, CHARSET); - } - - public void convertTo(Target t) { - try { - theTargetWriter = t.getWriter(); - while (handler.fillDataFrom(Source)) { - - theTargetWriter.getDatafrom(handler); - theTargetWriter.writeData(); - } - - } catch (IOException e) { - OutputHandler.out(e.getMessage()); - - } catch (Exception e) { - e.printStackTrace(); - } - - } - - } - /** - * Encapsulate writing to a SDF file - * - * @author Christian Schmidt 2005 - * - */ - private class SDFTarget implements Target { - - /** - * Create a new Instance of SDFTarget - * - * @throws IOException - */ - public SDFTarget() throws IOException { - File target = FileMaker.newFile(targetString, overwrite); - theTargetWriter = new SDFWriter(new BufferedOutputStream( - new FileOutputStream(target)), CHARSET); - } - - /* (non-Javadoc) - * @see com.sun.star.tooling.converter.Converter.Target#getWriter() - */ - public DataWriter getWriter() { - - return theTargetWriter; - } - - } - - /** - * The interface for all convertable sources - * - * @author Christian Schmidt 2005 - * - */ - private interface Source { - - DataReader Source=null; - /** - * Convert this. to the designated target - * @param target the target of the converting - * @throws IOException - */ - abstract void convertTo(Target target) throws IOException; - } - - /** - * The interface for all creatable targets - * - * @author Christian Schmidt 2005 - * - */ - private interface Target { - /** - * The writer to use - */ - public OutputStream writer = null; - - /** - * Get the writer - * this target uses to write the - * data in the correct format. - * - * @return the used DataWriter - */ - abstract DataWriter getWriter(); - - } - /** - * Encapsulate the reading from an XLIFF file - * - * @author Christian Schmidt 2005 - * - */ - private class XLIFFSource implements Source { - File source; - - /** - * Create a new Instance of XLIFFSource - * - * - */ - public XLIFFSource() { - - source = new File(sourceString); - } - - public void convertTo(Target t) throws IOException { - try { - System.setProperty("entityExpansionLimit", "1000000"); - boolean laden = source.canRead(); - if (laden) { - DefaultHandler contentHandler=null; - if("dbxliff".equalsIgnoreCase(sourceType)){ - contentHandler = new XLIFFReader(handler, t - .getWriter(),false); - }else{ - contentHandler = new XLIFFReader(handler, t - .getWriter()); - } - SAXParserFactory factory = SAXParserFactory.newInstance(); - factory.setNamespaceAware( true ); - factory.setValidating( true ); - - SAXParser parser=factory.newSAXParser(); - XMLReader xliffreader=parser.getXMLReader(); - - - -// XMLReader xliffreader = XMLReaderFactory -// .createXMLReader("org.apache.crimson.parser.XMLReaderImpl"); - xliffreader.setErrorHandler(contentHandler); - xliffreader.setContentHandler(contentHandler); - /* one possibility to resolve an extern entity (DTD) */ - EntityResolver res = new Resolver(); - 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 - * 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"); - } - - } catch (SAXParseException e) { - try { - theTargetWriter.flush(); - } catch (IOException e1) { - - e1.printStackTrace(); - } - OutputHandler.out("PARSE ERROR Zeile " + e.getLineNumber() - + ", " + e.getMessage()); - - }catch (SAXException e){ - try { - theTargetWriter.flush(); - } catch (IOException e1) { - - e1.printStackTrace(); - } - OutputHandler.out("PARSE EXCEPTION " + e.getMessage()); - } catch (ParserConfigurationException e) { - OutputHandler.out("PARSER Configuration failed\n " + e.getMessage()); - } - } - - } - /** - * Encapsulate writing to a XLIFF file - * - * @author Christian Schmidt 2005 - * - */ - private class XLIFFTarget implements Target { - File target; - - /** - * Create a new Instance of XLIFFTarget - * - * @throws FileNotFoundException - * @throws IOException - */ - public XLIFFTarget() throws FileNotFoundException, IOException { - target = FileMaker.newFile(targetString, overwrite); - theTargetWriter = new XLIFFWriter(new BufferedOutputStream( - new FileOutputStream(target)), CHARSET); - - } - - public DataWriter getWriter() { - - return theTargetWriter; - } - } - - -}
\ No newline at end of file diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/ConverterException.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/ConverterException.java deleted file mode 100755 index 0b630978098d..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/ConverterException.java +++ /dev/null @@ -1,76 +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. - * - ************************************************************************/ -/* - * a simple exception - * just to seperate - * it from other - * exceptions - */ -package com.sun.star.tooling.converter; - -/** - * @author Christian Schmidt - * - * Thrown if an error occurs during converting from one file format to another - * that does not belong to an other exception - */ -public class ConverterException extends Exception { - - /** - * - */ - public ConverterException() { - super(); - - } - - /** - * @param arg0 - */ - public ConverterException(String arg0) { - super(arg0); - - } - - /** - * @param arg0 - */ - public ConverterException(Throwable arg0) { - super(arg0); - - } - - /** - * @param arg0 - * @param arg1 - */ - public ConverterException(String arg0, Throwable arg1) { - super(arg0, arg1); - - } - -}
\ No newline at end of file diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/DataHandler.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/DataHandler.java deleted file mode 100755 index fcc95905d3be..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/DataHandler.java +++ /dev/null @@ -1,146 +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. - * - ************************************************************************/ -/* - * DataHandler.java - * - * take the data from the reader - * and put it to the Writer - * - */ - -package com.sun.star.tooling.converter; - -import java.util.*; - -/** - * Handle the Data to get it from the Source - * readable to the Target - * - * @author Christian Schmidt - */ -public class DataHandler { - - /** - * An arrays that holds the names that will be - * keys for the HashMap containing the data - * - */ - private final String[] dataNames = { "BlockNr", "Project", - "SourceFile", "Dummy", "ResType", "GID", "LID", "HID", "Platform", - "Width", "SourceLanguageID", "SourceText", "SourceHText", - "SourceQText", "SourceTitle", "TargetLanguageID", "TargetText", - "TargetHText", "TargetQText", "TargetTitle", "TimeStamp" }; - - private static final String EMPTY = new String(""); - - /** - * The HashMap containing the data - */ - private final Map data = new ExtMap(dataNames, null); - - /** Creates a new instance of DataHandler */ - public DataHandler() { - } - - /** - * fill the data from the desired source - * - * @param source where to get the data from - * @return true if data is read and false if null is read - * @throws IOException - * @throws ConverterException - */ - public boolean fillDataFrom(DataReader source) throws java.io.IOException, - ConverterException { - - Map line = null; - - line = source.getData(); - if (line == null){ - - return false; - }else{ - - this.data.putAll(line); - return true; - } - - - } - - /** - * fill this data with the inData - * - * @param inData the data to handle by this handler - */ - public void fillDataWith(Map inData) { - data.putAll(inData); - } - -// public void transfer(DataWriter target, DataReader source) { -// -// source.setHandler(this); -// -// } - - /** - * The designated output is filled with the content of this handler - * - * @param output an array of Maps [0] should hold the source language data [1] the target language data - * @throws java.io.IOException - */ - public void putDataTo(Map[] output) throws java.io.IOException { - String aKey = EMPTY; - for (int j = 0; j < output.length; j++) { - Set keys = output[j].keySet(); - Iterator iter = keys.iterator(); - while (iter.hasNext()) { - aKey = (String) iter.next(); - output[j].put(aKey, data.get(aKey)); - } - } - - } - /** - * The designated output is filled with the content of this handler - * - * @param output a Map that should hold the source language data and the target language data - * @throws java.io.IOException - */ - public void putDataTo(Map output) throws java.io.IOException { - String aKey = EMPTY; - - Set keys = output.keySet(); - Iterator iter = keys.iterator(); - while (iter.hasNext()) { - aKey = (String) iter.next(); - output.put(aKey, data.get(aKey)); - } - - } - -}
\ No newline at end of file diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/DataReader.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/DataReader.java deleted file mode 100755 index d6bb2ed85d73..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/DataReader.java +++ /dev/null @@ -1,76 +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. - * - ************************************************************************/ -package com.sun.star.tooling.converter; - -import java.io.*; -import java.util.*; - -/** - * Gets Line counting from LineNumberReader all Converter Reader classes inherit - * from this. - * The abstract parent class of all converter reader classes - * - * @author Christian Schmidt - */ -abstract public class DataReader extends LineNumberReader { - - /** - * Creates a new instance of DataReader - * - * @param isr - * InputStreamReader used as Source for this class - */ - public DataReader(InputStreamReader isr) { - super(isr); - } - - /** - - * @throws java.io.IOException - * @throws ConverterException - * - * TODO this should no longer use an array as return type better a Map - * - */ - /** - * The next block of the SDF file is reviewed and the Line including the - * source language and the Line including the target Language are given back - * in an array - * - * - * @return A Map including the source language - * and the target Language content are given back - * - * @throws java.io.IOException - * @throws ConverterException - */ - public Map getData() throws java.io.IOException, ConverterException { - return null; - } - - -}
\ No newline at end of file diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/DataWriter.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/DataWriter.java deleted file mode 100755 index 497bb54bbdb8..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/DataWriter.java +++ /dev/null @@ -1,88 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -/* - * DataWriter.java - * - * parent of all XXXWriter classes used by - * Converter - */ - -package com.sun.star.tooling.converter; - -import java.io.BufferedOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; - -/** - * The abstract parent class of all converter writer classes - * - * @author Christian Schmidt - */ -abstract public class DataWriter extends OutputStreamWriter { - protected final String seperator = new String("|"); - - /** - * the char sequence used as line seperator - */ - protected final String lineEnd = java.lang.System.getProperty( - "line.seperator", "\n"); - - /** Creates a new instance of DataWriter */ - /** - * @param bos the buffered output stream holding the data - * @param encoding the encoding to use for read from bos - * @throws java.io.UnsupportedEncodingException - */ - public DataWriter(BufferedOutputStream bos, String encoding) - throws java.io.UnsupportedEncodingException { - super(bos, encoding); - } - -// abstract protected void writeData(Map[] data) throws java.io.IOException; - - /** - * get the data that should be written from the DataHandler - * - * @param handler the DataHandler having the data - * @throws java.io.IOException - */ - abstract protected void getDataFrom(DataHandler handler) - throws java.io.IOException; - - /** - * write the Data - * - * @throws java.io.IOException - */ - abstract protected void writeData() throws java.io.IOException; - - /** - * @param handler - * @throws IOException - */ - abstract protected void getDatafrom(DataHandler handler) throws IOException; -}
\ No newline at end of file diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/ExtMap.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/ExtMap.java deleted file mode 100755 index a26665e1629e..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/ExtMap.java +++ /dev/null @@ -1,94 +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. - * - ************************************************************************/ -/* - * A special HashMap, - * can be constructed of - * two Arrays - */ -package com.sun.star.tooling.converter; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Christian Schmidt - * - * Create a Hash Map from two Arrays - * - */ -public class ExtMap extends HashMap { - - /** - * - */ - public ExtMap() { - super(); - - } - - /** - * @see java.util.HashMap - * @param arg0 - */ - public ExtMap(int arg0) { - super(arg0); - - } - - /** - * @param arg0 - * @param arg1 - */ - public ExtMap(int arg0, float arg1) { - super(arg0, arg1); - - } - - /** - * @param arg0 - */ - public ExtMap(Map arg0) { - super(arg0); - - } - - // create a new Map from two string arrays - public ExtMap(String[] names, String[] content) { - super(names.length); - if (content == null) - content = new String[names.length]; - for (int i = 0; i < names.length; i++) { - if (i >= content.length) { - break; - } else { - this.put(names[i], content[i]); - } - } - - } - -}
\ No newline at end of file diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/FileMaker.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/FileMaker.java deleted file mode 100755 index 600687c41d29..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/FileMaker.java +++ /dev/null @@ -1,84 +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. - * - ************************************************************************/ -/* - * creates new files - * checks if they exist or - * can be overwritten - * - */ -package com.sun.star.tooling.converter; - -import java.io.File; -import java.io.IOException; - -/** - * Creates new files only if the file does not yet exist - * or overwriting is allowed - * - * @author Christian Schmidt 2005 - * - */ -public final class FileMaker { - - /** - * Create a new file if overwriting is not alowed - * ask if existing files should be overwritten - * - * @param fileName the files name to overwrite - * @param overwrite indicates wether the file can be overwritten - * @return the File created from the fileName - * @throws IOException - */ - public final static File newFile(String fileName, boolean overwrite) - throws IOException { - File file = new File(fileName); - if (file.exists()) { - if (!overwrite) { - char c = 0; - - System.out.print("Warning: File " + fileName - + " already exist.\n" + "Overwrite (y/n) ? :"); - byte[] waste = new byte[10]; - System.in.read(waste); - c = (char) waste[0]; - if (c == 'y') { - OutputHandler.out("...overwriting " + fileName); - } else { - OutputHandler.out( - "\nPlease set '-o' switch at command line to overwrite.\n\nProgramm Aborted."); - System.exit(-1); - } - } else { - OutputHandler.out("...overwriting " + fileName); - } - } else { - OutputHandler.out("...creating new target file " + fileName); - } - return file; - } - -}
\ No newline at end of file diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/GSIReader.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/GSIReader.java deleted file mode 100755 index 398fcc9b686b..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/GSIReader.java +++ /dev/null @@ -1,247 +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. - * - ************************************************************************/ -/* - * Created on 2005 - * by Christian Schmidt - */ -package com.sun.star.tooling.converter; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.HashMap; -import java.util.Map; - -import com.sun.star.tooling.languageResolver.LanguageResolver; -import com.sun.star.tooling.languageResolver.LanguageResolver.LanguageResolvingException; - -/** - * @author Christian Schmidt 2005 - * - */ -public class GSIReader extends DataReader { - /** - * A Map holding an empty GSIBlock - */ - private Map EmptyGSIBlock; - - /** - * @see LanguageResolver - */ - LanguageResolver languageResolver; - - /** - * The source language identifier - */ - protected String sourceLanguage; - - /** - * The target language identifier - */ - protected String targetLanguage; - - /** - * The number of the last block - */ - private String oldBlockNr; - - /** - * A buffer holding one GSILine - */ - private Map GSILineBuffer; - - /** - * Indicates whether to use the buffered line - */ - private boolean useBuffer = false; - - private static final String EMPTY = new String(""); - - /** - * An empty Map to fill with language depending data - */ - private ExtMap EmptyLanguageMap; - - /** - * Indicates whether the first block is read - */ - private boolean isFirst = true; - - private int lineCounter; - - private int blockCounter; - /** - * Indicates whether the last line is read - */ - private boolean lastLineFound = false; - - /** - * Create a new Instance of GSIReader - * - * @param source - * the file to read from - * @param sourceLanguage - * the sourceLanguage (must not be empty) - * @param targetLanguage - * the targetLanguage - * @param charset - * the charset used to read source - * @throws java.io.IOException - * @throws Exception - */ - public GSIReader(File source, String sourceLanguage, String targetLanguage, - String charset) throws java.io.IOException { - super(new InputStreamReader(new FileInputStream(source), charset)); - this.languageResolver = new LanguageResolver(); - this.sourceLanguage = sourceLanguage; - this.targetLanguage = targetLanguage; - - EmptyLanguageMap = new ExtMap(new String[0], new String[0]); - - } - - /** - * Read the next GSIBlock and return the data - * - * @return A Map containing the data of the read GSIBlock the keys for the language depending data are the language id (numeric) the - * single language are acessible with the keys "BlockNr", "resType", "languageNr", "status","content". - * - * @throws IOException - */ - public Map getGSIData() throws IOException { - String help; - Map helpmap; - Map GSIBlock = new HashMap(); - GSIBlock.put(sourceLanguage, EmptyLanguageMap.clone()); - GSIBlock.put(targetLanguage, EmptyLanguageMap.clone()); - String line = EMPTY; - String[] splitLine; - Map GSILine; - String[] GSINames = { "BlockNr", "resType", "languageNr", "status", - "content" }; - - while (useBuffer || (line = readLine()) != null) { - - - - if (useBuffer) { - GSILine = GSILineBuffer; - GSIBlock.put(sourceLanguage, EmptyLanguageMap.clone()); - GSIBlock.put(targetLanguage, EmptyLanguageMap.clone()); - GSIBlock.put("BlockNr", GSILine.get("BlockNr")); - useBuffer = false; - } else { - this.lineCounter++; - if ((splitLine = split(line)) == null) { - continue; - } - GSILine = new ExtMap(GSINames, splitLine); - if (isFirst) { - GSIBlock.put("BlockNr", GSILine.get("BlockNr")); - oldBlockNr = (String) GSILine.get("BlockNr"); - isFirst = false; - } - } - if (oldBlockNr == null) { - oldBlockNr = (String) GSILine.get("BlockNr"); - } - if (!oldBlockNr.equals((String) GSILine.get("BlockNr"))) { - GSILineBuffer = GSILine; - oldBlockNr = (String) GSILine.get("BlockNr"); - useBuffer = true; - break; - } - String lang; - try { - // Is there the source language in this line? - if ((lang = languageResolver.getISOfromNr((String) GSILine - .get("languageNr"))).equals(this.sourceLanguage)) { - // ok..store it as Source String under the depending - // ressource type - - ((Map) GSIBlock.get(sourceLanguage)).put("Source" - + ResTypeResolver.getInternKey((String) GSILine - .get("resType")), GSILine.get("content")); - // ..maybe the target language? - } else { - if (targetLanguage.equals(EMPTY)) { - // if no target language is given at command line - targetLanguage = lang; - GSIBlock.put(targetLanguage, EmptyLanguageMap.clone()); - } - if (lang.equals(this.targetLanguage)) { - - // ok..store it as target String under the depending - // ressource type - ((Map) GSIBlock.get(targetLanguage)).put("Target" - + ResTypeResolver.getInternKey((String) GSILine - .get("resType")), GSILine - .get("content")); - } - } - } catch (LanguageResolvingException e) { - OutputHandler.out("Can not resolve the language "+e.getMessage()); - } - - } - if (line == null) { - if (lastLineFound){ - OutputHandler.out("\n\n"); - OutputHandler.out("GSI Blocks : " + this.blockCounter); - OutputHandler.out("GSI Lines : " + this.lineCounter); - - return null; - }else{ - lastLineFound = true; - this.blockCounter++; - return GSIBlock; - } - } else { - this.blockCounter++; - return GSIBlock; - } - - } - - /** - * Split a GSILine to single fields - * - * @param line - * The line to split - * @return An array containing the contents of the columns in the given line - */ - private String[] split(String line) { - String[] splitLine = (line.substring(0, line.length() - 1)) - .split("\\(\\$\\$\\)"); - if (splitLine.length != 5) - return null; - else - return splitLine; - } - -} diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/GSIWriter.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/GSIWriter.java deleted file mode 100755 index 0f7aee811569..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/GSIWriter.java +++ /dev/null @@ -1,243 +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. - * - ************************************************************************/ - -package com.sun.star.tooling.converter; -import java.io.*; -import java.util.Map; - -import com.sun.star.tooling.languageResolver.LanguageResolver; -import com.sun.star.tooling.languageResolver.LanguageResolver.LanguageResolvingException; -/** - * - * @author cs156069 - */ -public class GSIWriter extends DataWriter { - /** - * The seperator used to seperate GSI columns - */ - final String seperator=new String("($$)"); - - /** - * Holding the keys used by a map holding the content of an GSI Line contianing the source language - */ - final static String[] sourceLineNames= {"Project","SourceFile","Dummy","ResType","GID","LID","HID","Platform","Width","SourceLanguageID","SourceText","SourceHText","SourceQText","SourceTitle","TimeStamp"}; - /** - * Holding the keys used by a map holding the content of an GSI Line contianing the target language - */ - final static String[] targetLineNames= {"Project","SourceFile","Dummy","ResType","GID","LID","HID","Platform","Width","TargetLanguageID","TargetText","TargetHText","TargetQText","TargetTitle","TimeStamp"}; - /** - * Holding the keys used by a map holding the content of an GSI Line contianing the source and the target language - */ - final static String[] outLineNames= {"BlockNr","Project","SourceFile","Dummy","ResType","GID","LID","HID","Platform","Width","SourceLanguageID","SourceText","SourceHText","SourceQText","SourceTitle","TargetLanguageID","TargetText","TargetHText","TargetQText","TargetTitle","TimeStamp"}; - - /** - * A map holding the content of an GSI Line contianing the source language - */ - private ExtMap sourceLine=new ExtMap(sourceLineNames,null); - /** - * A map holding the content of an GSI Line contianing the target language - */ - private ExtMap targetLine=new ExtMap(targetLineNames,null); - /** - * A map holding the content of an GSI Line contianing the source and the target language - */ - private ExtMap outData=new ExtMap(outLineNames, null); - - private static final String EMPTY = new String(""); - /** - * The sourceLanguage to use - */ - private String sourceLanguage; - /** - * The sourceLanguage to use - */ - private String targetLanguage; - - /** - * GSILines have a special Line End - */ - private final static String lineEnd="!"+'\r'+'\n'; - //private boolean SourceIsFirst=false; - - /** - * The blockNr of the current line - */ - private String blockNr; - - - - - /** - * Create a new Instance of GSIWriter - * - * @param bos the Buffered Output Stream to write to - * @param charset the used charset - * @throws java.io.UnsupportedEncodingException - */ - public GSIWriter(BufferedOutputStream bos,String charset) throws java.io.UnsupportedEncodingException { - super(bos,charset); - - - - } - - /* (non-Javadoc) - * @see com.sun.star.tooling.converter.DataWriter#writeData() - */ - public final void writeData() throws java.io.IOException { - - StringBuffer buffer=new StringBuffer(""); - if(this.sourceLanguage==null&&this.targetLanguage==null){ - LanguageResolver lang =new LanguageResolver(); - try { - this.sourceLanguage=lang.getNrFromISO((String)outData.get("SourceLanguageID")); - this.targetLanguage=lang.getNrFromISO((String)outData.get("TargetLanguageID")); - } catch (LanguageResolvingException e) { - - OutputHandler.out(e.getMessage()); - System.exit(0); - } - } - - - this.blockNr=(String)outData.get("BlockNr"); - // get the values of the found fields - //create the gsi lines - // - //at first the source language line - buffer.append(getSourceLine("Text")); - buffer.append(getSourceLine("HText")); - buffer.append(getSourceLine("QText")); - buffer.append(getSourceLine("Title")); - - //now the target language line - // put them together for output - buffer.append(getTargetLine("Text")); - buffer.append(getTargetLine("HText")); - buffer.append(getTargetLine("QText")); - buffer.append(getTargetLine("Title")); - //ok...put all to disk; - this.write(buffer.toString()); - - } - - /** - * Create a line containing the source string from the data - * @param resType - * @return The StringBuffer containing the line - */ - private StringBuffer getSourceLine(String resType){ - StringBuffer buffer =new StringBuffer(200); - String resString = "Source"+resType; - - String help; - if(EMPTY.equals((String)outData.get(resString))||" ".equals(outData.get(resString))) return new StringBuffer(EMPTY); - else { - // put them together for output - buffer.append(this.blockNr); - // seperate the fields with ($$) - buffer.append(this.seperator); - buffer.append(ResTypeResolver.getExternKey(resType)); - // seperate the fields with ($$) - buffer.append(this.seperator); - buffer.append(this.sourceLanguage); - // seperate the fields with ($$) - buffer.append(this.seperator); - buffer.append("int"); - // seperate the fields with ($$) - buffer.append(this.seperator); - buffer.append(outData.get(resString)); - - // this line is full - // so close it with '! cr lf' - buffer.append(GSIWriter.lineEnd); - Converter.countLine(); - return buffer; - } - - } - /** - * Create a line containing the target string from the data - * @param resType - * @return The StringBuffer containing the line - */ - private StringBuffer getTargetLine(String resType){ - StringBuffer buffer =new StringBuffer(200); - String resString = "Target"+resType; - - if(EMPTY.equals((String)outData.get(resString))||" ".equals(outData.get(resString))) return new StringBuffer(EMPTY); - else { - // put them together for output - buffer.append(this.blockNr); - // seperate the fields with ($$) - buffer.append(this.seperator); - buffer.append(ResTypeResolver.getExternKey(resType)); - // seperate the fields with ($$) - buffer.append(this.seperator); - buffer.append(this.targetLanguage); - // seperate the fields with ($$) - buffer.append(this.seperator); - buffer.append("ext"); - // seperate the fields with ($$) - buffer.append(this.seperator); - buffer.append(outData.get(resString)); - - // this line is full - // so close it with '! cr lf' - buffer.append(GSIWriter.lineEnd); - Converter.countLine(); - return buffer; - } - - } - - - /* (non-Javadoc) - * @see com.sun.star.tooling.converter.DataWriter#writeData(java.util.Map[]) - */ - protected void writeData(Map[] data) throws IOException { - // TODO redesign DataHandler in the way that this is not nessesary any more - - } - - /* (non-Javadoc) - * @see com.sun.star.tooling.converter.DataWriter#getDataFrom(com.sun.star.tooling.converter.DataHandler) - */ - protected void getDataFrom(DataHandler handler) throws IOException { - - handler.putDataTo(this.outData); - } - - /* (non-Javadoc) - * @see com.sun.star.tooling.converter.DataWriter#getDatafrom(com.sun.star.tooling.converter.DataHandler) - */ - protected void getDatafrom(DataHandler handler) throws IOException { - - handler.putDataTo(this.outData); - - } -} diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/GSIandSDFMerger.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/GSIandSDFMerger.java deleted file mode 100755 index 526f3ca75640..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/GSIandSDFMerger.java +++ /dev/null @@ -1,164 +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. - * - ************************************************************************/ -/* - * Created on 2005 - * by Christian Schmidt - */ -package com.sun.star.tooling.converter; - -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -/** - * Merge GSIFiles back to to the original (!) SDFFile - * - * - * @author Christian Schmidt 2005 - * - */ -public class GSIandSDFMerger extends SDFReader { - - int lineCounter=0; - - GSIReader gsiReader; - - private Map temp=new HashMap(); - private int j; - private boolean skip=true; - Map gsiBlock=null; - Map sdfBlock=null; - - private boolean dontLoadGSI=false; - - private int count; - /** - * Merge the GSIFile back to the original(!) SDFFile - * - * @param source the file to read from - * @param sourceLanguage the source language in the source file - * @param targetLanguage the target language in the source file - * @param charset the charset of the files - * @throws java.io.IOException - * @throws Exception - */ - public GSIandSDFMerger(File source, File secondSource,String sourceLanguage, - String targetLanguage, String charset) throws IOException { - // merging GSI and SDF requieres two Sources - //this. is the SDF source - super(secondSource, sourceLanguage, targetLanguage, charset); - //create the GSI Source - - gsiReader=new GSIReader(source,sourceLanguage,targetLanguage,charset); - - } - - /* (non-Javadoc) - * @see com.sun.star.tooling.converter.DataReader#getData() - */ - public Map getData()throws java.io.IOException{ - do{ - skip=false; - this.temp=matchGSI(); - }while(skip); - if(temp==null){ - OutputHandler.out("Blocks merged : "+this.lineCounter); - } - return temp; - - } - - /** - * Read each block of the GSIFile and check whether there is a matching - * block in the SDFFile. Match depends on the BlockNr and BlockId. - * - * @return A Map that contains the source language content - * and the target language content. - * @throws IOException - * @throws ConverterException - */ - public Map matchGSI() throws IOException{ - - - try { - //System.out.println("Start..."); - - if (dontLoadGSI||(gsiBlock=gsiReader.getGSIData())!=null){ - dontLoadGSI=false; - //check if we must update this block - //if so its BlockNr is in the gsi file - if((sdfBlock = super.getData())!=null){ - - if(((String)sdfBlock.get("BlockNr")).equals((String)gsiBlock.get("BlockNr"))){ - - gsiBlock.remove(EMPTY); - //if the target language string is empty this may be caused by an error in the source sdf File - //I don't want to overwrite a possibly correct translation with an empty string - // so remove the target part from the gsiBlock - Map mp=(Map)gsiBlock.get(gsiReader.targetLanguage); - if (mp.size()!=0&&!((String)mp.get("TargetText")).equals("")){ - - // target language part in this gsiBlock -// if(((String)mp.get("TargetText")).equals("")){ -// gsiBlock.remove(targetLanguage); -// } - // count the merged blocks - lineCounter++; - Map helpMap = (Map)gsiBlock.get(super.targetLanguage);//"ja" - sdfBlock.putAll(helpMap); - skip=false; - }else{ - //no target language part in this gsiBlock - skip=true; -// -// return null; - } - }else{ -// skip=true; -// -// // we cant match this gsi block to the current sdf block - // try matching the next sdf block with this gsi line - dontLoadGSI=true; - } - } - return sdfBlock; - } - - } catch (IOException e) { - - e.printStackTrace(); - } - return null; - } - - - - - - -} diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/LineErrorException.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/LineErrorException.java deleted file mode 100755 index 26ce5a6518eb..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/LineErrorException.java +++ /dev/null @@ -1,78 +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. - * - ************************************************************************/ -/* - * Exception for errors in - * SDFLines - */ -package com.sun.star.tooling.converter; - - -/** - * This Exeption is thrown if a DataReader finds an error in a read Line - * f. e. wrong column number - * - * @author Christian Schmidt 2005 - * - */ -public class LineErrorException extends Exception { - - public int tokenCount; - /** - * - */ - public LineErrorException() { - super(); - - } - - /** - * @param arg0 - */ - public LineErrorException(String arg0) { - super(arg0); - - } - - /** - * @param arg0 - */ - public LineErrorException(Throwable arg0) { - super(arg0); - - } - - /** - * @param arg0 - * @param arg1 - */ - public LineErrorException(String arg0, Throwable arg1) { - super(arg0, arg1); - - } - - -}
\ No newline at end of file diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/OutputHandler.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/OutputHandler.java deleted file mode 100755 index 997a522acedb..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/OutputHandler.java +++ /dev/null @@ -1,225 +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. - * - ************************************************************************/ -/* - * Creates logfile and file for debug information - * - */ -package com.sun.star.tooling.converter; - -import java.io.BufferedWriter; -import java.io.IOException; - -/** - * Handle the whole output during converting process except the converted files. - * Write output to logfiles and to screen depending on switches given - * at command line. - * @author Christian Schmidt 2005 - * - */ -public class OutputHandler { - - private static final String EMPTY = ""; - - /** - * The logfile to write - */ - public static BufferedWriter logFile; - - /** - * Indicates whether excisting files should be overwritten - */ - public static boolean doLog = false; - - /** - * Indicate whether the debug information should be written - */ - public static boolean doDebug = false; - - /** - * The File to write the debug information to - */ - public static BufferedWriter dbgFile; - - /** - * Write the data to screen and if the switches were set to - * logfile and debugfile - * - * @param out the String to write - */ - final static void out(String out) { - try { - if (doDebug) - OutputHandler.dbg(out); - - if (!doLog || logFile == null) { - System.out.println(out); - } else { - System.out.println(out); - if (EMPTY.equals(out)) { - OutputHandler.log(EMPTY); - } else { - OutputHandler.log(out); - } - } - } catch (IOException e) { - - OutputHandler.log(e.toString()); - } - } - - /** - * make a dot on the screen to show the user that it is going on - */ - final static void printDot() { - System.out.print("."); - - } - - /** - * write the data to log file and if the switch is set - * to the debug file - * - * @param out the String to write - */ - final static void log(String out) { - try { - if(out==null) return; - if (doDebug) - - OutputHandler.dbg(out); - - if (doLog) { - if (!EMPTY.equals(out)) { - logFile.write(out); - } - logFile.newLine(); - logFile.flush(); - } - } catch (IOException e) { - - System.out.println(e.getMessage()); - } - } - - /** - * write the string to the debug file - * - * @param out the String to write - * @throws IOException - */ - final static void dbg(String out) throws IOException { - if(out==null) return; - if (doDebug) { - if (!EMPTY.equals(out)) { - dbgFile.write(out); - - } - dbgFile.newLine(); - dbgFile.flush(); - } - } - - /** - * Set a new value to indicate whether a debug file should be written or not - * - * @param doDebug - * The debug value to set. - */ - private static void setDebug(boolean doDebug) { - OutputHandler.doDebug = doDebug; - } - - // /** - // * @return Returns the doDebug. - // */ - // private static boolean isDebug() { - // return doDebug; - // } - - /** - * Set the debug file to write to. - * - * @param dbgFile - * The debug File to use. - */ - private static void setDbgFile(BufferedWriter dbgFile) { - OutputHandler.dbgFile = dbgFile; - } - - /** - * @return Returns the debug File. - */ - private static BufferedWriter getDbgFile() { - return dbgFile; - } - - /** - * @param doLog - * The log value to set. - */ - private static void setLog(boolean doLog) { - OutputHandler.doLog = doLog; - } - - /** - * @return Returns the log value. - */ - private static boolean isLog() { - return doLog; - } - - /** - * @param logFile - * The logFile to set. - */ - private static void setLogFile(BufferedWriter logFile) { - OutputHandler.logFile = logFile; - } - - /** - * @return Returns the logFile. - */ - private static BufferedWriter getLogFile() { - return logFile; - } - - /** - * @throws IOException - * close log and dbg - */ - public static void closeAll() throws IOException { - if (OutputHandler.logFile != null) { - OutputHandler.logFile.flush(); - OutputHandler.logFile.close(); - } - if (OutputHandler.dbgFile != null) { - OutputHandler.dbgFile.flush(); - OutputHandler.dbgFile.close(); - } - } - -}
\ No newline at end of file diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/ResTypeResolver.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/ResTypeResolver.java deleted file mode 100755 index 585f69fe2c88..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/ResTypeResolver.java +++ /dev/null @@ -1,68 +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. - * - ************************************************************************/ -/* - * Created on 2005 - * by Christian Schmidt - */ -package com.sun.star.tooling.converter; - -import java.util.Map; - -/** - * Helps resolving restype descriptors used outside the tool to - * restype descriptors used by this tool - * - * @author Christian Schmidt 2005 - * - */ -public class ResTypeResolver { - final static String[] inFields={"Text","QText","HText","Title"}; - final static String[] outFields={"res","res-quickhelp","res-help","res-title"}; - final static Map internKeys=new ExtMap(inFields,outFields); - final static Map externKeys=new ExtMap(outFields,inFields); - - /** - * Get the intern key depending to the given extern key - * - * @param externKey the externKey {"res","res-quickhelp","res-help","title"} - * @return the depending intern key - */ - public static String getInternKey(String externKey){ - return (String)externKeys.get(externKey); - } - - /** - * Get the extern key to the given intern key - * - * @param internKey the internal key - * @return the external key - */ - public static String getExternKey(String internKey){ - return (String)internKeys.get(internKey); - } - -} diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/Resolver.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/Resolver.java deleted file mode 100755 index 557731fe88f1..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/Resolver.java +++ /dev/null @@ -1,95 +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. - * - ************************************************************************/ -/* - * Created on 27.01.2005 - * - */ -package com.sun.star.tooling.converter; - -import java.io.IOException; -import java.io.InputStream; - -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -/** - * Resolve external entities by provide the - * XLIFF DTD stored in the jar file - */ -public class Resolver implements EntityResolver { - - /** - * Resolver constructor. - */ - public Resolver() { - } - - /** - * Allow the application to resolve external entities. - * - * The Parser will call this method before opening any external entity - * except the top-level document entity (including the external DTD subset, - * external entities referenced within the DTD, and external entities - * referenced within the document element): the application may request that - * the parser resolve the entity itself, that it use an alternative URI, or - * that it use an entirely different input source. - */ - - /* (non-Javadoc) - * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String) - */ - - public InputSource resolveEntity(String publicId, String systemId) - throws SAXException, IOException { - - if ((publicId != null) && (publicId.equals("-//XLIFF//DTD XLIFF//EN"))) { - systemId = "dtd:///xliff.dtd"; - } - if (systemId != null) { - if (systemId.startsWith("dtd://")) { - String dtd = "com/sun/star/tooling/converter/dtd" - + systemId.substring(6); - ClassLoader cl = this.getClass().getClassLoader(); - InputStream in = cl.getResourceAsStream(dtd); - InputSource ins = new InputSource(in); - ins.setSystemId(systemId); - return ins; - } /* - * else if ( systemId.startsWith("jar:") ) { try { URL url=new - * URL(systemId); JarURLConnection jarConn = - * (JarURLConnection)url.openConnection(); InputSource ins=new - * InputSource(jarConn.getInputStream()); - * ins.setSystemId(systemId); return ins; } - * catch(MalformedURLException me){ throw new SAXException(me); - * Incorrect URL format used } } - */ - } - return null; - } - -}
\ No newline at end of file diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/SDFReader.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/SDFReader.java deleted file mode 100755 index 9e47ae73c719..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/SDFReader.java +++ /dev/null @@ -1,632 +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. - * - ************************************************************************/ -/* - * SDFReader.java - * - * - */ - -package com.sun.star.tooling.converter; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.text.DecimalFormat; -import java.util.*; - -/** - * - * SDFReader is a FileReader that knows about - * the content of SDFFiles - * - * A SDFBlock is read of the given file. A SDFBlock - * consists of all SDFLines that are traanslations of the - * same String and the SDFLine containing the source string - * itself. SDFFile lines are read and checked whether they - * have the allowed column count and don't contain illeagal - * characters (like most unprintable characters below 0x00df). - * If the given source language is not found in the first - * block of SDFLines a ConverterException is thrown at runtime. - * If the given target language is "" (that means not given) - * the first language that is not the given source language - * is taken for target language. The found values are returned in HashMaps that - * use the following keys: - * <br/> - * "BlockNr" originally coming from reading the sdf file, contains 'block nr in sdf file'+'-'+'hash value of the sdf id fields'.<br/> - * "Project" first column in sdf file format.<br/> - * "SourceFile" second column in sdf file format.<br/> - * "Dummy" third column in sdf file format.<br/> - * "ResType" 4. column in sdf file format.<br/> - * "GID" 5. column in sdf file format. <br/> - * "LID" 6. column in sdf file format.<br/> - * "HID" 7. column in sdf file format.<br/> - * "Platform" 8. column in sdf file format. <br/> - * "Width", 9. column in sdf file format.<br/> - * "SourceLanguageID" 10. column in sdf file format(in the line with the source language).<br/> - * "SourceText" 11. column in sdf file format(in the line with the source language).<br/> - * "SourceHText" 12. column in sdf file format(in the line with the source language).<br/> - * "SourceQText" 13. column in sdf file format(in the line with the source language).<br/> - * "SourceTitle" 14. column in sdf file format(in the line with the source language).<br/> - * "TargetLanguageID" 10. column in sdf file format (in the line with the target language).<br/> - * "TargetText" 11. column in sdf file format (in the line with the target language).<br/> - * "TargetHText" 12. column in sdf file format (in the line with the target language).<br/> - * "TargetQText" 13. column in sdf file format (in the line with the target language).<br/> - * "TargetTitle", 14. column in sdf file format (in the line with the target language).<br/> - * "TimeStamp" 15. column in sdf file format.<br/> - * - * @author Christian Schmidt 2005 - * - */ - -public class SDFReader extends DataReader { - - /** - * an array of the SDF files column names - */ - final static String[] fieldnames = { "Project", "SourceFile", "Dummy", - "ResType", "GID", "LID", "HID", "Platform", "Width", "LanguageID", - "Text", "HText", "QText", "Title", "TimeStamp" }; - - /** - * an array of the SDF files column names if the source language is in - */ - final static String[] sourceLineNames = { "Project", "SourceFile", "Dummy", - "ResType", "GID", "LID", "HID", "Platform", "Width", - "SourceLanguageID", "SourceText", "SourceHText", "SourceQText", - "SourceTitle", "TimeStamp" }; - - /** - * an array of the SDF files column names if the target language is in - */ - final static String[] targetLineNames = { "Project", "SourceFile", "Dummy", - "ResType", "GID", "LID", "HID", "Platform", "Width", - "TargetLanguageID", "TargetText", "TargetHText", "TargetQText", - "TargetTitle", "TimeStamp" }; - - final static String EMPTY = new String(""); - - private int dotCount = 0; - - /** - * a Map containing an SDF line with source language - */ - private Map sourceMap; - - /** - * a Map containing an SDF line with target language - */ - private Map targetMap; - - /** - * a Map containing an SDF - */ - private Map SDFMap; - - /** - * a Map Array containing one SDF source language line and one SDF target - * language line - */ - private Map[] data = { sourceMap, targetMap }; - - /** - * The Id of the current SDFBlock - */ - private String CurrentBlockId; - - /** - * The SDF file to read from - */ - private File sourceFile; - - /** - * The language in the source file that should be handelt as source language - */ - protected String sourceLanguage; - - /** - * The language in the source file that should be handelt as target language - */ - protected String targetLanguage; - - /** - * A counter holding the number of blocks just read - * from this file - */ - private long blockNr = 0;// If we use Integer, more then numbers greater than 128k would be signed - - /** - * A counter holding the number of skipped lines that means - * lines that can not be worked with because they contain an error - */ - private int skippedLines = 0; - - /** - * This switch is set for indicating that all source file lines - * are read and no lines remain buffered. Finding this like 'true' - * means the source file is finished - */ - private boolean endIt = false; - - /** - * Indicates whether the targetLanguage is found in this source file so far - */ - private boolean foundTarget = false; - /** - * Indicates whether the sourceLanguage is found in this source file so far - */ - private boolean foundSource = false; - - /** - * Counts how many lines were skipped because the language is - * neither sourceLanguage nor targetLanguage - */ - private int langMiss; - - /** - * Indicates whether there is a line in the read buffer or not - */ - private boolean useBuffer = false; - - /** - * A buffer for SDFLines - */ - private String lineBuffer; - - /** - * The buffer for the already splitted SDFLines - */ - private String[] splittedLineBuffer; - - /** - * Counts how many Blocks were skipped - * f.e. because no sourceLanguage is found - * in it - */ - private int skippedBlocks; - - /** - * Counts the blocks without targetLanguage - */ - private int targetLangMiss; - - /** - * Counts the blocks without sourceLanguage - */ - private int sourceLangMiss; - - /** - * Counts the lines where no targetLanguage line was found - * and so empty lines were created - */ - private int targetLangCreate; - - - DecimalFormat blockNrFormatter = new DecimalFormat("000000"); - - /** - * The hashcode of the current block - */ - private int CurrentBlockHash; - - private boolean skip; - - /** - * Create a new Instance of SDFREader - * - * @param source the file to read from - * @param sourceLanguage the sourceLanguage (must not be empty) - * @param targetLanguage the targetLanguage - * @param charset the charset used to read source - * @throws java.io.IOException - * @throws Exception - */ - public SDFReader(File source, String sourceLanguage, String targetLanguage, - String charset) throws java.io.IOException { - super(new InputStreamReader(new FileInputStream(source), charset)); - sourceFile = source; - this.sourceLanguage = sourceLanguage; - this.targetLanguage = targetLanguage; - String line; - String[] splitLine; - //read first line to get the first - //SDF block id - mark(16000); - if ((line = readLine()) != null) { - if ((splitLine = split(line)) != null){ - this.CurrentBlockId = getSDFBlockId(splitLine); - this.CurrentBlockHash=this.CurrentBlockId.hashCode(); - //found the first - this.blockNr++; - } - this.splittedLineBuffer = splitLine; - } - reset(); - - } - - /* (non-Javadoc) - * @see com.sun.star.tooling.converter.DataReader#getData() - */ - public Map getData()throws IOException { - - Map map=new HashMap(); -// do { - this.skip=false; - Map[] help=readBlock(); - if(help==null||help[1]==null||help[0]==null){ - return null; -// }else if (help[1].get("TargetLanguageID")==null||help[0].get("SourceLanguageID")==null) { -// OutputHandler.log("Missing Language Id in block "+blockNr+"\nthe block is skipped." ); -// this.skippedBlocks++; -// this.skip=true; - }else{ - map.putAll(help[1]); - map.putAll(help[0]); - - } -// }while(this.skip=true); - return map; - } - - - /** - * Read a Block from the sdf file and return - * @return a Map[] where [0] holds the source and [1] the target language data. - * - * @throws java.io.IOException - */ - public Map[] readBlock() throws java.io.IOException { - String line = EMPTY; - String blockId = EMPTY; - String[] splittedLine = null; - data[0]=new ExtMap(); - data[1]=new ExtMap(); - String help; - String c = null; - //read next line or use buffered line - while (useBuffer || (line = readLine()) != null) { //works because '||' is shortcut - - try { - // buffer used? - if (useBuffer) { - line = this.lineBuffer; - splittedLine = this.splittedLineBuffer; - this.SDFMap = new ExtMap(SDFReader.fieldnames, splittedLine); - - try { - checkLanguage(splittedLine); - } catch (ConverterException e) { - throw e; - }finally{ - - useBuffer = false; - } - } else { - //...are there wrong characters? - if ((check(line)).length() < line.length()) { - throw new LineErrorException(getLineNumber() - + " : Line contains wrong character " - //+ Integer.toHexString(Integer.parseInt(c)) - + " \n" + line); - } - //...is the number of columns ok? - if ((splittedLine = split(line)) == null) { - - throw new LineErrorException(super.getLineNumber() - + " : Line has wrong column number \n" + line); - //continue; - } else { - // TODO makeDot is better in Data Handler - makeDot(); - // ...is this line in a new SDF block ? - if ((blockId = getSDFBlockId(splittedLine)) - .equals(CurrentBlockId)) { - - this.SDFMap = new ExtMap(SDFReader.fieldnames, - splittedLine); - //what language is in it ? - checkLanguage(splittedLine); - - } else { - - /* - * we found the next block , but do we have the - * target text? - */ - - if (!foundTarget) { - createTargetLine(); - } - - blockNr++; - splittedLineBuffer = splittedLine;//read one line - // too much so - // buffer it - lineBuffer = line; - useBuffer = true;//reset(); - - this.CurrentBlockId = blockId; - this.CurrentBlockHash=this.CurrentBlockId.hashCode(); - - /* ...and what about the source text ? */ - if (!foundSource) { - - OutputHandler - .log("Error in Line:" - + getLineNumber() - + "Source Language is missing maybe " - + "previous block has an error.\nBlock " - + (blockNr - 1) - + " is skipped. before line: \n" - + line); - - foundTarget = false;//no target without source - skippedBlocks++; - skippedLines++; - sourceLangMiss++; - continue;// skip output of this block if no - // source language is found - - } - - break; - - } - } - - } - - } catch (LineErrorException e) { - - OutputHandler.log(e.getMessage()); - this.skippedLines++; - } catch (ConverterException e) { - OutputHandler.log(e.getMessage()); - } - - } - // did we read the whole stuff? - if (null != line) { - // no - foundSource = false; - foundTarget = false; - - return this.data; - - } else { - // ok , its the end but is everything written now? - if (!endIt) { - // there is something to write - // but next time we can end it - endIt = true; - if(!foundTarget){ - createTargetLine(); - } - // write - return this.data;//last lines - } else { - - showStat(); - return null; - } - } - // }catch(ConverterException e) { - // Converter.log(e.getMessage()); - // return null; - // } - } - - /** - * - */ - private void createTargetLine() { - targetLangMiss++; - // if not, create one ... - data[1] = new ExtMap(SDFReader.targetLineNames, - splittedLineBuffer); - data[1].put("TargetLanguageID", - this.targetLanguage); - if ((String) data[1].get("TargetText") != EMPTY) - data[1].put("TargetText", EMPTY); - if ((String) data[1].get("TargetHText") != EMPTY) - data[1].put("TargetHText", EMPTY); - if ((String) data[1].get("TargetQText") != EMPTY) - data[1].put("TargetQText", EMPTY); - if ((String) data[1].get("TargetTitle") != EMPTY) - data[1].put("TargetTitle", EMPTY); - this.data[1].put("BlockNr", blockNrFormatter.format(blockNr)+'-'+Integer.toString(this.CurrentBlockHash)); - targetLangCreate++; - } - - /** - * Show the statistic information got while - * reading the file - * - * @throws IOException - */ - private void showStat() throws IOException { - OutputHandler.out(EMPTY);OutputHandler.out(EMPTY); - // OutputHandler.out("Hashes: " + (theHashes.size()) + " "); - OutputHandler.out("Blocks found: " + blockNr + " "); - OutputHandler.out(EMPTY); - OutputHandler.out("Lines read: " + (getLineNumber()) + " "); - OutputHandler - .dbg("Lines created " + (targetLangCreate) + " "); - OutputHandler.dbg(" -------"); - OutputHandler.dbg("Lines total: " - + (getLineNumber() + targetLangCreate) + " "); - OutputHandler.dbg("Lines skipped: " + skippedLines + " "); - - OutputHandler.dbg("Source Language misses: " + sourceLangMiss + " "); - OutputHandler.dbg("Target Language misses: " + targetLangMiss + " "); - OutputHandler.dbg("Blocks found: " + blockNr + " "); - OutputHandler.dbg("Blocks skipped: " + skippedBlocks + " "); - if ((sourceLangMiss + skippedBlocks + skippedLines) > 0) - OutputHandler.out("\n---! Errors found !--- view Logfile.\n\n" - + "To enable logfile use -l option at command line.\n" - + "For help type 'convert -h {Enter}'.\n"); - } - - /** - * Check the current line whether the source language - * or target language is in it - * - * @throws ConverterException if a not needed language or no target language is found - * in this block - * @throws IOException - * - */ - final private void checkLanguage(String[] splittedLine) - throws ConverterException, IOException { - String langID = (String) SDFMap.get("LanguageID"); - - //maybe the source language is in this line - if (!foundSource && this.sourceLanguage.equals(langID)) { -// found the next source language line - this.data[0] = new ExtMap(SDFReader.sourceLineNames, splittedLine); - -// this.data[0].put("BlockNr", Integer.toHexString(blockNr)); -// this.data[0].put("BlockHash", Integer.toHexString(this.CurrentBlockHash)); - this.data[0].put("BlockNr", blockNrFormatter.format(blockNr)+'-'+Integer.toHexString(this.CurrentBlockHash)); -// this.data[0].put("BlockHash", blockHashFormatter.format(this.CurrentBlockHash)); - foundSource = true; - return; - - } else { - // or the target language is in this line - if (!foundTarget) { - //no target language is given at command line - if (this.targetLanguage.equals(EMPTY)) { - //try if we can use the current lines language for target - // language - if (!langID.equals(this.sourceLanguage)) { - //yes , we can use this lines laanguage as target - this.targetLanguage = langID; - - //source and target language both are known: show it - OutputHandler.out("Source Language is: " - + this.sourceLanguage + " "); - OutputHandler.out("Target Language is: " - + this.targetLanguage + " "); - OutputHandler.out(EMPTY); - System.out.println("Start"); - - } else { - throw new ConverterException("(" + getLineNumber() - + ") No target language found: " - + this.targetLanguage); - } - } - if (this.targetLanguage.equals(langID)) { - this.data[1] = new ExtMap(SDFReader.targetLineNames, - splittedLine);// found the next target language line - this.data[1].put("BlockNr", blockNrFormatter.format(blockNr)+'-'+Integer.toHexString(this.CurrentBlockHash)); - foundTarget = true; - - return; - } - }//end !foundTarget - } - //if we go here we dont need the found language... - throw new ConverterException("found not needed language '" - + this.SDFMap.get("LanguageID") + "' in Line: " - + getLineNumber()); - - } - - /** - * Make a dot on the screen to show the user that it is going on - */ - private void makeDot() { - int count = 0; - if ((count = (int) super.getLineNumber() / 1000) > this.dotCount) { - this.dotCount = count; - OutputHandler.printDot(); - } - - } - - /** - * split the SDFLine in its columns - * - * @param line the current SDFLine - * @return the splitted SDFLine as array of String - * or null if an error occours - * @throws IOException - */ - private String[] split(String line) throws IOException { - check(line); - String[] splitLine; - if ((splitLine = line.split("\t")).length == 15) - return splitLine; - else - //an error occured - return null; - } - - /** - * create a block Id from a splitted SDFLine - * the blockId consists of the column one to eight of an SDF File - * - * @param splitLine the line to create a block id from - * @return the blockId as String - */ - private String getSDFBlockId(String[] splitLine) { - StringBuffer BlockId = new StringBuffer(""); - for (int i = 0; i < 8; i++) { - BlockId.append(splitLine[i]); - } - return BlockId.toString(); - } - -// public final boolean canRead() { -// return this.sourceFile.canRead(); -// } - - /** - * Check if there are not allowed characters in this line - * - * @param line the SDFLine to check - * @return if everything, ok the original - * else the wrong character as String - * - * @throws java.io.IOException - */ - private String check(String line) throws java.io.IOException { - char c = ' '; - for (int i = 0; i < line.length(); i++) { - c = line.charAt(i); - if (c < 30 && c != 9) { - return (new Character(c)).toString(); - } - - } - return line; - - } -}
\ No newline at end of file diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/SDFWriter.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/SDFWriter.java deleted file mode 100755 index 4c79cd113f6f..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/SDFWriter.java +++ /dev/null @@ -1,172 +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. - * - ************************************************************************/ -/* - * SDFWriter.java - * - * - */ - -package com.sun.star.tooling.converter; -import java.io.*; -import java.util.Map; - -/** - * Write data to a SDFFile - * - * @author Christian Schmidt 2005 - * - */ -public class SDFWriter extends DataWriter { - /** - * the seperator the seperate columns - */ - final String seperator=new String("\t"); - /** - * an array of the SDF files column names if the source language is in - */ - final static String[] sourceLineNames= {"Project","SourceFile","Dummy","ResType","GID","LID","HID","Platform","Width","SourceLanguageID","SourceText","SourceHText","SourceQText","SourceTitle","TimeStamp"}; - /** - * an array of the SDF files column names if the target language is in - */ - final static String[] targetLineNames= {"Project","SourceFile","Dummy","ResType","GID","LID","HID","Platform","Width","TargetLanguageID","TargetText","TargetHText","TargetQText","TargetTitle","TimeStamp"}; - /** - * an array of the SDF files column names if the source and the target language is in - */ - final static String[] outLineNames= {"BlockNr","Project","SourceFile","Dummy","ResType","GID","LID","HID","Platform","Width","SourceLanguageID","SourceText","SourceHText","SourceQText","SourceTitle","TargetLanguageID","TargetText","TargetHText","TargetQText","TargetTitle","TimeStamp"}; - - /** - * A Map holding the source language line content - */ - private ExtMap sourceLine=new ExtMap(sourceLineNames,null); - /** - * A Map holding the target language line content - */ - private ExtMap targetLine=new ExtMap(targetLineNames,null); - /** - * A Map holding the whole content for output - */ - private ExtMap outData=new ExtMap(outLineNames, null); -// private ExtMap SDFLine; -// private InputStreamReader isr; - /** - * The language to translate from - */ - private String sourceLanguage; - /** - * The language to translate to - */ - private String targetLanguage; - -// private boolean SourceIsFirst=false; - - - - - /** - * Create a new Instance of SDFWriter - * - * @param bos BufferedWriter to write to - * @param charset the charset to use to write - * @throws java.io.UnsupportedEncodingException - */ - public SDFWriter(BufferedOutputStream bos,String charset) throws java.io.UnsupportedEncodingException { - super(bos,charset); - - } - - /* (non-Javadoc) - * @see com.sun.star.tooling.converter.DataWriter#writeData() - */ - public final void writeData() throws java.io.IOException { - - StringBuffer buffer=new StringBuffer(""); - - // get the values of the found fields - //create the two sdf lines - - //at first the source language line - for(int i=0;i<sourceLineNames.length;i++){ - // put them together for output - buffer.append(outData.get(sourceLineNames[i])); - if(i!=sourceLineNames.length-1) { - // seperate the fields with tab - buffer.append(seperator); - }else{ - // this line is full - // so close it with lf - buffer.append(lineEnd); - Converter.countLine(); - } - } - // is there a target line with anything in the strings? - if (!(outData.get("TargetLanguageID")==null||((outData.get("TargetTitle").equals("")&&outData.get("TargetText").equals("")&&outData.get("TargetHText").equals("")&&outData.get("TargetQText").equals(""))))){ - //now the target language line - for(int i=0;i<targetLineNames.length;i++){ - // put them together for output - buffer.append(outData.get(targetLineNames[i])); - if(i!=targetLineNames.length-1) { - // seperate the fields with tab - buffer.append(seperator); - }else{ - // this line is full - //so close it with lf - buffer.append(lineEnd); - Converter.countLine(); - } - } - } - this.write(buffer.toString()); - - } - - - - /* (non-Javadoc) - * @see com.sun.star.tooling.converter.DataWriter#writeData(java.util.Map[]) - */ - protected void writeData(Map[] data) throws IOException { - // TODO redesign DataHandler in the way that this is not nessesary any more - - } - - /* (non-Javadoc) - * @see com.sun.star.tooling.converter.DataWriter#getDataFrom(com.sun.star.tooling.converter.DataHandler) - */ - protected void getDataFrom(DataHandler handler) throws IOException { - - handler.putDataTo(this.outData); - } - - /* (non-Javadoc) - * @see com.sun.star.tooling.converter.DataWriter#getDatafrom(com.sun.star.tooling.converter.DataHandler) - */ - protected void getDatafrom(DataHandler handler) throws IOException { - - handler.putDataTo(this.outData); - - } -} diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/XLIFFReader.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/XLIFFReader.java deleted file mode 100755 index 76d14bd98569..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/XLIFFReader.java +++ /dev/null @@ -1,742 +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. - * - ************************************************************************/ -/* - * XLIFFReader.java - * - * - */ -package com.sun.star.tooling.converter; - -import java.io.IOException; -import java.util.Hashtable; -import java.util.Map; - -import com.sun.star.tooling.languageResolver.LanguageResolver; - -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; -import org.xml.sax.helpers.AttributesImpl; -import org.xml.sax.helpers.DefaultHandler; - - -/** - * Parse the given file and extract the content needed. - * <br/> - * This Reader understands the parts of the - * <a href="http://www.oasis-open.org/committees/xliff/documents/cs-xliff-core-1.1-20031031.htm">xliff</a> spezification used to translate - * the strings in Star-Office and Open-Office. - * <br/> - * The given file is parsed and the content is stored in a HashMap with those keys: - * <br/> - * "BlockNr" originally coming from reading the sdf file, contains 'block nr in sdf file'+'-'+'hash value of the sdf id fields'.<br/> - * "Project" first column in sdf file format.<br/> - * "SourceFile" second column in sdf file format.<br/> - * "Dummy" third column in sdf file format.<br/> - * "ResType" 4. column in sdf file format.<br/> - * "GID" 5. column in sdf file format. <br/> - * "LID" 6. column in sdf file format.<br/> - * "HID" 7. column in sdf file format.<br/> - * "Platform" 8. column in sdf file format. <br/> - * "Width", 9. column in sdf file format.<br/> - * "SourceLanguageID" 10. column in sdf file format(in the line with the source language).<br/> - * "SourceText" 11. column in sdf file format(in the line with the source language).<br/> - * "SourceHText" 12. column in sdf file format(in the line with the source language).<br/> - * "SourceQText" 13. column in sdf file format(in the line with the source language).<br/> - * "SourceTitle" 14. column in sdf file format(in the line with the source language).<br/> - * "TargetLanguageID" 10. column in sdf file format (in the line with the target language).<br/> - * "TargetText" 11. column in sdf file format (in the line with the target language).<br/> - * "TargetHText" 12. column in sdf file format (in the line with the target language).<br/> - * "TargetQText" 13. column in sdf file format (in the line with the target language).<br/> - * "TargetTitle", 14. column in sdf file format (in the line with the target language).<br/> - * "TimeStamp" 15. column in sdf file format.<br/> - * @ - * @author Christian Schmidt 2005 - * - */ -public class XLIFFReader extends DefaultHandler { - - /** - * A String array holding the keys used by the HashMap holding the Data - */ - private final String[] dataNames = { "BlockNr", "Project", - "SourceFile", "Dummy", "ResType", "GID", "LID", "HID", "Platform", - "Width", "SourceLanguageID", "SourceText", "SourceHText", - "SourceQText", "SourceTitle", "TargetLanguageID", "TargetText", - "TargetHText", "TargetQText", "TargetTitle", "TimeStamp" }; - - /** - * Used to index in the data array - */ - static int index = 0; - - /** - * The Map that holds the data returned by this class - */ - private Map moveData = new ExtMap(); - - /** - * A Map that holds yet incomplete data - * until all depending transunits are found - */ - private Hashtable DataStore = new Hashtable(); - - /** - * An Elements name - */ - private String name = new String(""); - - /** - *List of Attributes used by an Element - */ - private Attributes attrs; - -// private String tagElement = new String(""); - - /** - * Indicates whether the next found content string should be printed - */ - private boolean printThis = false; - /** - * Indicates whether the next found content string should be stored - */ - private boolean storeIt = false; - - /** - * data holds the information created while parsing - * - */ - private String[] data = new String[26]; - - /** - * The handler used by this class - */ - private final DataHandler handler; - /** - * The target used by this class - */ - private final DataWriter target; - -// private boolean searchForText = false; - - /** - * counts how many dots are made - */ - private int dotCount; - - /** - * Counts how many Trans Units are read - */ - private int transUnitCounter; - - /** - * used source Language - */ - private String sourceLanguage; - - /** - * used target language - */ - private String targetLanguage; - - /** - * indicates whether this is the first Transunit - */ - private boolean isFirst = true; - - private static final String EMPTY = new String(""); - - /** - * the last index in data where something is written - */ - private int oldindex; - -// private boolean isBptEptTag; - -// private String innerString; -// -// private String key; - - /** - * Index for the BlockNr in the data array - */ - private static final int BLOCKNR_IDX = 0; - /** - * Index for the Project in the data array - */ - private static final int PROJECT_IDX = 1; - /** - * Index for the Sourcefile name in the data array - */ - private static final int SOURCEFILE_IDX = 2; - /** - * Index for the 'dummy' in the data array - */ - private static final int DUMMY_IDX = 3; - /** - * Index for the Group Id in the data array - */ - private static final int GID_IDX = 4; - /** - * Index for the Local Id in the data array - */ - private static final int LID_IDX = 5; - /** - * Index for the Help Id in the data array - */ - private static final int HID_IDX = 6; - /** - * Index for the Platform in the data array - */ - private static final int PLATFORM_IDX = 7; - /** - * Index for the 'Width' in the data array - */ - private static final int WIDTH_IDX = 8; - /** - * Index for the Sourcelanguage Id in the data array - */ - private static final int SOURCE_LANGUAGE_ID_IDX = 10; - /** - * Index for the Source Text in the data array - */ - private static final int SOURCE_TEXT_IDX = 11; - /** - * Index for the Source Helptext in the data array - */ - private static final int SOURCE_HELPTEXT_IDX = 12; - /** - * Index for the Source Quickhelp Text in the data array - */ - private static final int SOURCE_QUICK_HELPTEXT_IDX = 13; - /** - * Index for the Source Titletext in the data array - */ - private static final int SOURCE_TITLETEXT_IDX = 14; - /** - * Index for the Timestamp in the data array - */ - private static final int TIMESTAMP_IDX = 15; - /** - * Index for the res type in the data array - */ - private static final int RESTYPE_IDX = 16; - /** - * Index for the Target Language Id in the data array - */ - private static final int TARGET_LANGUAGE_ID_IDX = 20; - /** - * Index for the Target Text in the data array - */ - private static final int TARGET_TEXT_IDX = 21; - /** - * Index for the Target Helptext in the data array - */ - private static final int TARGET_HELP_TEXT_IDX = 22; - /** - * Index for the Target Quickhelp Text in the data array - */ - private static final int TARGET_QUICKHELP_TEXT_IDX = 23; - /** - * Index for the Target Titletext in the data array - */ - private static final int TARGET_TITLE_TEXT_IDX = 24; - /** - * Index for the Found Parts Counter in the data array - */ - private static final int FOUND_PARTS_COUNTER_IDX = 18; - - /** - * used to find the matching ISO or RFC3066 language code - */ - LanguageResolver languageResolver; - - private boolean doBlockCompleteCheck=true; - - - - /** - * Create a new Instance of XLIFFReader - * - * @param handler the DataHandler to use - * @param target the target used - * @throws IOException - */ - public XLIFFReader(DataHandler handler, DataWriter target) throws IOException { - this.languageResolver = new LanguageResolver(); - this.handler = handler; - this.target = target; - } - - /** - * Create a new Instance of XLIFFReader - * - * @param handler the DataHandler to use - * @param target the target used - * @param doBlockCompleteCheck indicates whether every single transunit should be returned or the whole block data is to be collected - * - * @throws IOException - */ - public XLIFFReader(DataHandler handler, DataWriter target,boolean doBlockCompleteCheck) throws IOException { - this(handler, target); - this.languageResolver = new LanguageResolver(); - this.doBlockCompleteCheck=doBlockCompleteCheck; - - } - - /** - * delete and initialize the data content - */ - public void initData() { - for (int i = BLOCKNR_IDX; i < SOURCE_LANGUAGE_ID_IDX; i++) { - data[i] = ""; - } - for (int i = SOURCE_TEXT_IDX; i < TIMESTAMP_IDX; i++) { // skip Time Stamp - data[i] = ""; - } - for (int i = RESTYPE_IDX; i < TARGET_LANGUAGE_ID_IDX; i++) { // skip Source language ID - data[i] = ""; - } - for (int i = TARGET_TEXT_IDX; i < 26; i++) {// skip Target language ID, - data[i] = ""; - } - - data[DUMMY_IDX] = "0";//dummy - data[FOUND_PARTS_COUNTER_IDX] = "1";//parts found - - } - - /** (non-Javadoc) - * @see org.xml.sax.ContentHandler#startDocument() - */ - public void startDocument() { - initData(); - //System.out.print("Start"); - - } - - /** (non-Javadoc) - * @see org.xml.sax.ContentHandler#endDocument() - */ - public void endDocument() { - - try { - showStatistic(); - } catch (IOException e) { - - OutputHandler.log(e.getMessage()); - - } - } - - /** (non-Javadoc) - * @throws SAXException - * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) - */ - public void startElement(String namespaceURI, String sName, String qName, - Attributes attrs) throws SAXException { - this.name = new String(qName); - this.attrs = new AttributesImpl(attrs); - String resType; - - String attributeName = new String(""); - String attribute = new String(""); - String tagElement = new String(""); - int i; - - if (qName.equals("bpt")||qName.equals("ept")||qName.equals("sub")||qName.equals("ex")) { - //ignore bpt, ept, ex and sub tags - // content of the tags will be stored - - storeIt=true; - return; - - } - if (qName.equals("target")) { - if ((resType = data[RESTYPE_IDX]) == null) { - - } else { - if ("res".equals(resType)) { - index = TARGET_TEXT_IDX; - - storeIt = true; - return; - } - // if("res-Help".equals(resType)){ - // index=TARGET_HELP_TEXT_IDX; - // storeIt=true; - // return; - // } - if ("res-QuickHelp".equals(resType)) { - index = TARGET_QUICKHELP_TEXT_IDX; - - storeIt = true; - return; - } - if ("res-Title".equals(resType)) { - index = TARGET_TITLE_TEXT_IDX; - - storeIt = true; - return; - } - } - - } - if (qName.equals("source")) { - if ((resType = data[RESTYPE_IDX]) == null) { - //throw new SAXException("Ressource type not found"); - } else { - if ("res".equals(resType)) { - index = SOURCE_TEXT_IDX; - - storeIt = true; - return; - } - // if("res-Help".equals(resType)){ - // index=SOURCEHELPTEXT_IDX; - // storeIt=true; - // return; - // } - if ("res-QuickHelp".equals(resType)) { - index = SOURCE_QUICK_HELPTEXT_IDX; - storeIt = true; - return; - } - if ("res-Title".equals(resType)) { - index = SOURCE_TITLETEXT_IDX; - storeIt = true; - return; - } - } - } - - if (qName.equals("file")) { - data[TIMESTAMP_IDX] = attrs.getValue("date"); - //data[17]=(attrs.getValue("original")); - try{ - data[SOURCE_LANGUAGE_ID_IDX] = (languageResolver.getISOFromRFC((String)attrs.getValue("source-language"))); - if(languageResolver.getISOFromRFC((String)attrs.getValue("target-language"))!=null){ - data[TARGET_LANGUAGE_ID_IDX] = (languageResolver.getISOFromRFC((String)attrs.getValue("target-language"))); - } - }catch(Exception e){ - OutputHandler.log(e.getMessage()); - } - return; - } - if (qName.equals("trans-unit")) { - String id = attrs.getValue("id"); - if ((DataStore.get(id)) != null) { - //TODO arraycopy might not be nessessary - System.arraycopy((String[]) DataStore.get(id), 0, data, 0, - data.length); - int help = (new Integer(data[FOUND_PARTS_COUNTER_IDX])).intValue(); //found one more part - help++; // refresh the actual found parts - data[FOUND_PARTS_COUNTER_IDX] = (new Integer(help)).toString(); // belonging to this information - - DataStore.remove(attrs.getValue("id")); // TODO this can be deleted? - } else { - - data[BLOCKNR_IDX] = (attrs.getValue("id")); // a new part - } - data[RESTYPE_IDX] = (attrs.getValue("restype")); - - return; - } - - if (qName.equals("context")) { - - String value = attrs.getValue("context-type"); - - if ("SourceHelpText".equals(value)) { - index = SOURCE_HELPTEXT_IDX; - storeIt = true; - return; - }else if ("TargetHelpText".equals(value)) { - index = TARGET_HELP_TEXT_IDX; - storeIt = true; - return; - }else if ("DBType".equals(value)) { - //index=SOURCEFILE_IDX; - //storeIt=true; - return; - }else if ("Project".equals(value)) { - index = PROJECT_IDX; - storeIt = true; - return; - }else if ("Filename".equals(value)) { - index = SOURCEFILE_IDX; - storeIt = true; - return; - }else if ("Type".equals(value)) { - index = RESTYPE_IDX; - storeIt = true; - return; - }else if ("GID".equals(value)) { - index = GID_IDX; - storeIt = true; - return; - }else if ("LID".equals(value)) { - index = LID_IDX; - storeIt = true; - return; - }else if ("HID".equals(value)) { - index = HID_IDX; - storeIt = true; - return; - }else if ("Platform".equals(value)) { - index = PLATFORM_IDX; - storeIt = true; - return; - }else if ("Width".equals(value)) { - index = WIDTH_IDX; - storeIt = true; - return; - } - - } - - } - - /** (non-Javadoc) - * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String) - */ - public void endElement(String namespaceURI, String sName, String qName) - throws SAXException { - //we ignore bpt and ept tags - if(!(qName.equals("bpt")||qName.equals("ept")||qName.equals("sub")||qName.equals("ex"))){ - storeIt = false; - } - if (qName.equals("trans-unit")) { - showData(); - } - - } - - /** (non-Javadoc) - * @see org.xml.sax.ContentHandler#characters(char[], int, int) - */ - public void characters(char[] ch, int start, int length) { - - // checkContent(); - String str2 = new String(ch, start, length); - - if (storeIt) { - - String str = new String(ch, start, length); - if (index == oldindex) { - data[index] += str; - } else { - data[index] = str; - } - - } - oldindex = index; - - } - - /** (non-Javadoc) - * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException) - */ - public void error(SAXParseException e) throws SAXParseException { - - OutputHandler.log(e.getMessage()); - } - - /** (non-Javadoc) - * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException) - */ - public void fatalError(SAXParseException e) throws SAXParseException { - - OutputHandler.log("PARSE ERROR in line " + e.getLineNumber() + ", " - + e.getMessage() ); - - } - - /** (non-Javadoc) - * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException) - */ - public void warning(SAXParseException e) throws SAXParseException { - //throw e; - OutputHandler.log(e.getMessage()); - } - - /** - * Put the Data to the DataHandler - * tell the Writer to write it - * - * @throws SAXException - */ - public void showData() throws SAXException { - transUnitCounter++; - makeDot(); - if (isComplete()) { - - try { - moveData(); - if (isFirst == true) { - this.sourceLanguage = (String) this.moveData - .get("SourceLanguageID"); - this.targetLanguage = (String) this.moveData - .get("TargetLanguageID"); - OutputHandler.out(EMPTY); - OutputHandler.out("Source Language is: " - + this.sourceLanguage); - OutputHandler.out("Target Language is: " - + this.targetLanguage); - OutputHandler.out(EMPTY); - OutputHandler.out("Start"); - OutputHandler.out(EMPTY); - isFirst = false; - } - target.getDataFrom(handler); - target.writeData(); - - } catch (java.io.IOException e) { - throw new SAXException(e); - } - - } else { - DataStore.put(data[BLOCKNR_IDX], data.clone()); - initData(); - - } - initData(); - } - - - /** - * put the data in an Map in the format that - * DataHandler can handle it - */ - final public void moveData() { - - moveData.put("BlockNr", data[BLOCKNR_IDX]); - - moveData.put("Project", data[PROJECT_IDX]); - - moveData.put("SourceFile", data[SOURCEFILE_IDX]); - - moveData.put("Dummy", "0"); - - moveData.put("ResType", data[RESTYPE_IDX]); - - moveData.put("GID", data[GID_IDX]); - - moveData.put("LID", data[LID_IDX]); - - moveData.put("HID", data[HID_IDX]); - - moveData.put("Platform", data[PLATFORM_IDX]); - - if (EMPTY.equals(data[WIDTH_IDX])) - data[WIDTH_IDX] = "0"; - moveData.put("Width", data[WIDTH_IDX]); - - moveData.put("SourceLanguageID", data[SOURCE_LANGUAGE_ID_IDX]); - - moveData.put("SourceText", data[SOURCE_TEXT_IDX]); - - moveData.put("SourceHText", data[SOURCE_HELPTEXT_IDX]); - - moveData.put("SourceQText", data[SOURCE_QUICK_HELPTEXT_IDX]); - - moveData.put("SourceTitle", data[SOURCE_TITLETEXT_IDX]); - - moveData.put("TargetLanguageID", data[TARGET_LANGUAGE_ID_IDX]); - - moveData.put("TargetText", data[TARGET_TEXT_IDX]); - - moveData.put("TargetHText", data[TARGET_HELP_TEXT_IDX]); - - moveData.put("TargetQText", data[TARGET_QUICKHELP_TEXT_IDX]); - - moveData.put("TargetTitle", data[TARGET_TITLE_TEXT_IDX]); - - moveData.put("TimeStamp", data[TIMESTAMP_IDX]); - - //and give it to the data handler - this.handler.fillDataWith(moveData); - } - - /** - * complete means all depending parts have been found esp. all res types - * that belong to the same SDF Line - * - * @return true if the data is complete - * - */ - final public boolean isComplete() { - - if(!doBlockCompleteCheck){ - return true; - } - - String sParts; - if (data[FOUND_PARTS_COUNTER_IDX] == EMPTY) - data[FOUND_PARTS_COUNTER_IDX] = "1"; //this is the first part - - String sFoundParts = data[FOUND_PARTS_COUNTER_IDX]; - //create the new 'id' - sParts = data[BLOCKNR_IDX].substring(data[BLOCKNR_IDX].lastIndexOf(":") + 1); - - if (sFoundParts.equals(sParts)) { - return true; - } - return false; - } - - // TODO this belongs in OutputHandler - /** - * show the user that it is going - * on by printing dots on the screen - * - */ - private void makeDot() { - int count = 0; - if ((count = (int) this.transUnitCounter / 1000) > this.dotCount) { - this.dotCount = count; - OutputHandler.printDot(); - } - } - - /** - * show the statistic data found while parse this file - * - * @throws IOException - */ - final void showStatistic() throws IOException { - OutputHandler.out(EMPTY); - OutputHandler.out("TransUnits found: " + this.transUnitCounter); - // every data in DataStore is - // skipped 'cause its not complete - // TODO count really every transunit not only the data (might consist of - // more than one - OutputHandler.dbg("TransUnits skip : " + this.DataStore.size()); - //Converter.out(EMPTY); - } -} - diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/XLIFFWriter.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/XLIFFWriter.java deleted file mode 100755 index d7b6160dcc95..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/XLIFFWriter.java +++ /dev/null @@ -1,532 +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. - * - ************************************************************************/ -/* - * - /* - * XLIFFWriter.java - * - * - */ - -package com.sun.star.tooling.converter; - -import java.io.*; -import java.util.*; - -import com.sun.star.tooling.DirtyTags.DirtyTagWrapper; -import com.sun.star.tooling.languageResolver.LanguageResolver; -import com.sun.star.tooling.languageResolver.LanguageResolver.LanguageResolvingException; - -/** - * Write the Data to a wellformed XLIFF File - * - * @author Christian Schmidt - */ -public class XLIFFWriter extends DataWriter { - - /** - * An array holding the keys of the HashMap containing the source language string - */ - private final static String[] sourceLineNames = { "Project", "SourceFile", - "Dummy", "ResType", "GID", "LID", "HID", "Platform", "Width", - "SourceLanguageID", "SourceText", "SourceHText", "SourceQText", - "SourceTitle", "TimeStamp" }; - /** - * An array holding the keys of the HashMap containing the target language string - */ - private final static String[] targetLineNames = { "Project", "SourceFile", - "Dummy", "ResType", "GID", "LID", "HID", "Platform", "Width", - "TargetLanguageID", "TargetText", "TargetHText", "TargetQText", - "TargetTitle", "TimeStamp" }; - /** - * An array holding the keys of the HashMap containing the source and target language string - */ - private final static String[] outLineNames = { "BlockNr", "Project", - "SourceFile", "Dummy", "ResType", "GID", "LID", "HID", "Platform", - "Width", "SourceLanguageID", "SourceText", "SourceHText", - "SourceQText", "SourceTitle", "TargetLanguageID", "TargetText", - "TargetHText", "TargetQText", "TargetTitle", "TimeStamp" }; - /** - * An Map holding the source and target content - */ - private final Map data = new ExtMap(outLineNames, null); - - - /** - * Indicates if this is the first Transunit to write - */ - boolean isFirst = true; - - LanguageResolver languageResolver; - - - /** - * Create a new Instance of XLIFFWriter - * - * @param bos the Buffered Output Stream to write to - * @param charset the charset to use - * @throws IOException - */ - public XLIFFWriter(BufferedOutputStream bos, String charset) - throws IOException { - super(bos, charset); - this.languageResolver =new LanguageResolver(); - - - } - - /* (non-Javadoc) - * @see com.sun.star.tooling.converter.DataWriter#getDatafrom(com.sun.star.tooling.converter.DataHandler) - */ - public void getDatafrom(DataHandler handler) throws java.io.IOException { - handler.putDataTo(this.data); - } - - /** - * check if the item is an empty String - * - * @param item the string to check - * @return true if it is not empty, false if it is empty - */ - private final boolean isUsed(String item) { - if (!"".equals(item)) - return true; - return false; - } - - /** - * Replaces all characters that mustn't be in XLIFF PCdata - * - * @param string the string to check - * @return the checked string with all characters replaced - * @throws java.io.IOException - */ - private final String xmlString( final String string) throws java.io.IOException { - if (string == null) - return string; // "" - String str = string; -// str = str.replaceAll("&", "&"); -// str = str.replaceAll("<", "<"); -// str = str.replaceAll(">", ">"); -// str = str.replaceAll("\"", """); -// str = str.replaceAll("'", "'"); - for(int i=0;i<str.length();i++){ - if(str.charAt(i)=='&'){ - str=str.substring(0, i)+"&"+str.substring(i+1); - continue; - } - - if(str.charAt(i)=='<'){ - str=str.substring(0, i)+"<"+str.substring(i+1); - continue; - } - - if(str.charAt(i)=='>'){ - str=str.substring(0, i)+">"+str.substring(i+1); - continue; - } - - if(str.charAt(i)=='"'){ - str=str.substring(0, i)+"""+str.substring(i+1); - continue; - } - - if(str.charAt(i)=='\''){ - str=str.substring(0, i)+"'"+str.substring(i+1); - continue; - } - } - - return str; - } - - /* (non-Javadoc) - * @see java.io.Writer#close() - */ - public void close() throws IOException { - this.writeTrailer(); - - super.close(); - } - - /* (non-Javadoc) - * @see com.sun.star.tooling.converter.DataWriter#writeData() - */ - public void writeData() throws IOException { - if (isFirst) { - - writeHeader(); - isFirst = false; - } - try{ - writeTransUnit(); - }catch(DirtyTagWrapper.TagWrapperException e){ - - } - } - - /** - * Write the XLIFFFiles header - * - * @throws IOException - */ - private void writeHeader() throws IOException { - - this.write(getHeader()); - } - - /** - * Write the XLIFFFiles Trailer - * - * @throws IOException - */ - private void writeTrailer() throws IOException { - this.write(getTrailer()); - } - - /** - * Write the next TransUnit - * - * @throws IOException - */ - private void writeTransUnit() throws IOException, DirtyTagWrapper.TagWrapperException { - try{ - StringBuffer writeBuffer = new StringBuffer(1000); - - StringBuffer allLinesEnd = new StringBuffer(200); - String sRessource = ""; - int parts = 0; - if (data == null) { - OutputHandler.out("error");// TBD Exception - } - - if (!(this.data.get("SourceText").equals("") || this.data.get( - "SourceText").equals(" "))) { - parts++; - } - // if(!(this.data.get("SourceHText").equals("")||this.data.get("SourceHText").equals(" - // "))){ - // parts++; - // } - if (!(this.data.get("SourceQText").equals("") || this.data.get( - "SourceQText").equals(" "))) { - parts++; - } - if (!(this.data.get("SourceTitle").equals("") || this.data.get( - "SourceTitle").equals(" "))) { - parts++; - } - if (!(this.data.get("SourceText").equals("") || this.data.get( - "SourceText").equals(" "))) { - sRessource = "res"; // normal TEXT source - - allLinesEnd - .append("\t\t\t\t<context-group name=\"StarOffice Attributes\">\n"); - - if (isUsed((String) this.data.get("ResType"))) - allLinesEnd - .append("\t\t\t\t\t<context context-type=\"DBType\">" - + xmlString((String) this.data.get("ResType")) - + "</context>\n"); - if (isUsed((String) this.data.get("Project"))) - allLinesEnd - .append("\t\t\t\t\t<context context-type=\"Project\">" - + xmlString((String) this.data.get("Project")) - + "</context>\n"); - if (isUsed((String) this.data.get("SourceFile"))) - allLinesEnd - .append("\t\t\t\t\t<context context-type=\"Filename\">" - + xmlString((String) this.data - .get("SourceFile")) + "</context>\n"); - if (isUsed((String) this.data.get("SourceHText"))) - allLinesEnd - .append("\t\t\t\t\t<context context-type=\"SourceHelpText\">" - + xmlString((String) this.data - .get("SourceHText")) + "</context>\n"); - if (isUsed((String) this.data.get("TargetHText"))) - allLinesEnd - .append("\t\t\t\t\t<context context-type=\"TargetHelpText\">" - + xmlString((String) this.data - .get("TargetHText")) + "</context>\n"); - if (isUsed((String) this.data.get("ResType"))) - allLinesEnd.append("\t\t\t\t\t<context context-type=\"Type\">" - + xmlString((String) this.data.get("ResType")) - + "</context>\n"); - if (isUsed((String) this.data.get("GID"))) - allLinesEnd.append("\t\t\t\t\t<context context-type=\"GID\">" - + xmlString((String) this.data.get("GID")) - + "</context>\n"); - if (isUsed((String) this.data.get("LID"))) - allLinesEnd.append("\t\t\t\t\t<context context-type=\"LID\">" - + xmlString((String) this.data.get("LID")) - + "</context>\n"); - if (isUsed((String) this.data.get("HID"))) - allLinesEnd.append("\t\t\t\t\t<context context-type=\"HID\">" - + xmlString((String) this.data.get("HID")) - + "</context>\n"); - if (isUsed((String) this.data.get("Platform"))) - allLinesEnd - .append("\t\t\t\t\t<context context-type=\"Platform\">" - + xmlString((String) this.data.get("Platform")) - + "</context>\n"); - if (isUsed((String) this.data.get("Width"))) - allLinesEnd.append("\t\t\t\t\t<context context-type=\"Width\">" - + xmlString((String) this.data.get("Width")) - + "</context>\n"); - allLinesEnd.append("\t\t\t\t</context-group>\n" - + "\t\t\t</trans-unit>\n"); - - writeBuffer.append("\t\t\t<trans-unit id=\"" - + this.data.get("BlockNr") + ":" + parts + "\" restype=\"" - + sRessource + "\" translate=\"yes\">\n"); - if (isUsed((String) this.data.get("SourceText"))) - writeBuffer.append("\t\t\t\t<source xml:lang=\"" - + languageResolver.getRFCFromISO((String)this.data.get("SourceLanguageID")) + "\">" - + DirtyTagWrapper.wrapString((String) this.data.get("SourceText")) - + "</source>\n"); - - if (isUsed((String) this.data.get("TargetText"))) - writeBuffer - .append("\t\t\t\t<target state=\"to_translate\" xml:lang=\"" - + languageResolver.getRFCFromISO((String)this.data.get("TargetLanguageID")) - + "\">" - +DirtyTagWrapper.wrapString((String) this.data - .get("TargetText")) + "</target>\n"); - writeBuffer.append(allLinesEnd); - Converter.countLine(); - - } - // if(!(this.data.get("SourceHText").equals("")||this.data.get("SourceHText").equals(" - // "))){ - // sRessource="res-Help"; //Source is Help - // //sLineNumber=String.valueOf(iLineNumber);// - // writeBuffer.append("\t\t<trans-unit - // id=\""+this.data.get("BlockNr")+":"+parts+"\" - // restype=\""+sRessource+"\" translate=\"yes\">\n");//always translate - // if(isUsed((String)this.data.get("SourceHText"))) - // writeBuffer.append("\t\t\t<source - // xml:lang=\""+this.data.get("SourceLanguageID")+"\">"+xmlString((String)this.data.get("SourceHText"))+"</source>\n"); - // if(isUsed((String)this.data.get("TargetHText"))) - // writeBuffer.append("\t\t\t<target state=\"to_translate\" - // xml:lang=\""+this.data.get("TargetLanguageID")+"\">"+xmlString((String)this.data.get("TargetHText"))+"</target>\n"); - // writeBuffer.append(allLinesEnd); - // Converter.countLine(); - // } - - if (!(this.data.get("SourceQText").equals("") || this.data.get( - "SourceQText").equals(" "))) { - sRessource = "res-QuickHelp"; // Source is OuickHelp - // sLineNumber=String.valueOf(iLineNumber);// - writeBuffer.append("\t\t\t<trans-unit id=\"" - + this.data.get("BlockNr") + ":" + parts + "\" restype=\"" - + sRessource + "\" translate=\"yes\">\n");// always translate - if (isUsed((String) this.data.get("SourceQText"))) - writeBuffer.append("\t\t\t\t<source xml:lang=\"" - + languageResolver.getRFCFromISO((String)this.data.get("SourceLanguageID")) + "\">" - + DirtyTagWrapper.wrapString((String) this.data.get("SourceQText")) - + "</source>\n"); - if (isUsed((String) this.data.get("TargetQText"))) - writeBuffer - .append("\t\t\t\t<target state=\"to_translate\" xml:lang=\"" - + languageResolver.getRFCFromISO((String)this.data.get("TargetLanguageID")) - + "\">" - + DirtyTagWrapper.wrapString((String) this.data - .get("TargetQText")) + "</target>\n"); - writeBuffer.append(allLinesEnd); - Converter.countLine(); - } - - if (!(this.data.get("SourceTitle").equals("") || this.data.get( - "SourceTitle").equals(" "))) { - sRessource = "res-Title"; // Source is Title - - writeBuffer.append("\t\t\t<trans-unit id=\"" - + this.data.get("BlockNr") + ":" + parts + "\" restype=\"" - + sRessource + "\" translate=\"yes\">\n");// always translate - if (isUsed((String) this.data.get("SourceTitle"))) - writeBuffer.append("\t\t\t\t<source xml:lang=\"" - + languageResolver.getRFCFromISO((String)this.data.get("SourceLanguageID")) + "\">" - + DirtyTagWrapper.wrapString((String) this.data.get("SourceTitle")) - + "</source>\n"); - if (isUsed((String) this.data.get("TargetTitle"))) - writeBuffer - .append("\t\t\t\t<target state=\"to_translate\" xml:lang=\"" - + languageResolver.getRFCFromISO((String)this.data.get("TargetLanguageID")) - + "\">" - + DirtyTagWrapper.wrapString((String) this.data - .get("TargetTitle")) + "</target>\n"); - writeBuffer.append(allLinesEnd); - Converter.countLine(); - } - this.write(writeBuffer.toString()); - }catch(Exception e){ - OutputHandler.log(e.getMessage()); - } - } - - /** - * Create the XLIFFFiles Header - * - * @return the header as string - * @throws java.io.UnsupportedEncodingException - */ - private String getHeader() throws java.io.UnsupportedEncodingException { - return new String( - (getProcessingInstructionTag() + getDTDLine() - + openVersionLine() + openFileLine() + getHeaderTag() + openBodyTag()) - .getBytes(), "UTF8"); - - } - - /** - * Create the XLIFFFiles Trailer - * - * @return the trailer as string - */ - private String getTrailer() { - return closeBodyTag() + closeFileLine() + closeVersionLine(); - } - - /** - * Create the Processing Instruction Tag used by this XLIFFFile - * @return the Processing Instruction Tag used by this XLIFFFile - */ - private String getProcessingInstructionTag() { - String sPITagStart = "<?"; - String sPIName = "xml "; - String sPIVersion = "version=\"1.0\" "; - String sPIEncoding = "encoding=\"UTF-8\""; - String sPITagEnd = "?>"; - return sPITagStart + sPIName + sPIVersion + sPIEncoding - + /* sPIStandalone+ */sPITagEnd + '\n'; - } - - /** - * Create the line holding the DTD referenced by this XLIFFFile - * @return a string holding the DTD referenced by this XLIFFFile - */ - private String getDTDLine() { - String sDTDTagStart = "<!DOCTYPE "; - String sDTDType = "xliff "; - String sDTDSource = "PUBLIC \"-//XLIFF//DTD XLIFF//EN\" \"http://www.oasis-open.org/committees/xliff/documents/xliff.dtd\">";// http://www.oasis-open.org/committees/xliff/documents/ - String sDTSTagEnd = ">"; - return sDTDTagStart + sDTDType + sDTDSource + '\n'; - } - - /** - * Create the beginning of the line holding the version of this XIFFFile - * - * @return a string with the beginning of the line holding the version of this XIFFFile - */ - private String openVersionLine() { - return "<xliff version=\"1.0\">\n"; - } - /** - * Create the ending of the line holding the version of this XIFFFile - * - * @return a string with the ending of the line holding the version of this XIFFFile - */ - private String closeVersionLine() { - return "</xliff>"; - } - /** - * Create the beginning of the line holding the file tag of this XIFFFile - * - * @return a string with the beginning of the file tag of this XIFFFile - */ - private String openFileLine() { - - String FileTagStart = "\t<file"; - String FileDataType = " datatype=\"STAROFFICE\""; - String FileDate = " date=\"" + this.data.get("TimeStamp") + "\""; - String FileOriginal = " original=\"" + this.data.get("SourceFile") - + "\""; - String FileSourceLanguage=""; - String FileTargetLanguage=""; - try { - FileSourceLanguage = " source-language=\"" - + languageResolver.getRFCFromISO((String)this.data.get("SourceLanguageID")) + "\" "; - FileTargetLanguage = " target-language=\"" - + languageResolver.getRFCFromISO((String)this.data.get("TargetLanguageID")) + "\" "; - } catch (LanguageResolvingException e) { - OutputHandler.out(e.getMessage()); - } - String FileTagEnd = ">"; - return FileTagStart + FileDataType + FileDate + FileOriginal - + FileSourceLanguage + FileTargetLanguage + FileTagEnd; - - } - /** - * Create the ending of the line holding the file tag of this XIFFFile - * - * @return a string with the ending of the file tag of this XIFFFile - */ - private String closeFileLine() { - return "\t</file>"; - } - /** - * Create a String containing the header tag - * @return the String containing the header tag - */ - private String getHeaderTag() { - return "<header></header>\n"; - } - /** - * Create the begining of the line holding the body tag of this XIFFFile - * - * @return a string with the begining of the body tag of this XIFFFile - */ - private String openBodyTag() { - return "\t\t<body>\n"; - } - /** - * Create the ending of the line holding the body tag of this XIFFFile - * - * @return a string with the ending of the body tag of this XIFFFile - */ - private String closeBodyTag() { - return "\t\t</body>"; - } - - /* - * (non-Javadoc) - * - * @see com.sun.star.tooling.converter.DataWriter#writeData(java.util.Map[]) - */ - protected void writeData(Map[] data) throws IOException { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see com.sun.star.tooling.converter.DataWriter#getDataFrom(com.sun.star.tooling.converter.DataHandler) - */ - protected void getDataFrom(DataHandler handler) { } - -} diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/dtd/xliff.dtd b/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/dtd/xliff.dtd deleted file mode 100755 index 91262ec28204..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/converter/dtd/xliff.dtd +++ /dev/null @@ -1,391 +0,0 @@ -<!-- XLIFF - -Public Identifier: "-//XLIFF//DTD XLIFF//EN" - -History of modifications (latest first): - -Jul-14-2003 by YS: Added extype definition (was missing) -Jan-28-2003 by YS: Implemented fixes for resname -Jan-28-2002 by YS: Implemented fixes after OASIS TC spec revision -May-15-2001 by YS: Add phase-name to <trans-unit> and <bin-unit> -May-15-2001 by YS: Reverse id for <trans-unit> to required -Apr-19-2001 by YS: Enda+JohnR last changes -Apr-18-2001 by YS: Removed empty ATTLISTs -Apr-12-2001 by YS: Changed target* to target+ in trans-match -Apr-11-2001 by YS: Fixed DOCTYPE id -Apr-10-2001 by YS: Synchronize from conference call -Apr-05-2001 by YS: Synchronize with latest specs -Apr-04-2001 by YS: Synchronize with latest specs -Apr-03-2001 by YS: Added name in <prop-group> -Apr-02-2001 by YS: Implemented JR fixes -Mar-29-2001 by JC: fixes for xml:space and bin-unit -Mar-28-2001 by YS: First draft version - ---> - - -<!ENTITY % CodeContent "#PCDATA|sub" > -<!ENTITY % TextContent "#PCDATA|g|bpt|ept|ph|it|mrk|x|bx|ex" > - -<!ENTITY lt "&#60;" > -<!ENTITY amp "&#38;" > -<!ENTITY gt ">" > -<!ENTITY apos "'" > -<!ENTITY quot """ > - - -<!-- ***************************************************************** --> -<!-- Structural Elements --> -<!-- ***************************************************************** --> - -<!ELEMENT xliff (file)+ > -<!ATTLIST xliff - version CDATA #FIXED "1.0" - xml:lang CDATA #IMPLIED -> - -<!ELEMENT file (header,body) > -<!ATTLIST file - original CDATA #REQUIRED - source-language CDATA #REQUIRED - datatype CDATA #REQUIRED - tool CDATA #IMPLIED - date CDATA #IMPLIED - xml:space (default|preserve) "default" - ts CDATA #IMPLIED - category CDATA #IMPLIED - target-language CDATA #IMPLIED - product-name CDATA #IMPLIED - product-version CDATA #IMPLIED - build-num CDATA #IMPLIED -> -<!-- tool default = "manual" --> - - -<!ELEMENT header (skl?,phase-group?,(prop-group|glossary|reference|note|count-group)*) > - -<!ELEMENT skl (internal-file|external-file) > - -<!ELEMENT internal-file (#PCDATA) > -<!ATTLIST internal-file - form CDATA #IMPLIED - crc NMTOKEN #IMPLIED -> -<!-- text|base64 (text is default) --> - -<!ELEMENT external-file EMPTY > -<!ATTLIST external-file - href CDATA #REQUIRED - crc NMTOKEN #IMPLIED - uid NMTOKEN #IMPLIED -> - -<!ELEMENT glossary (internal-file|external-file) > - -<!ELEMENT reference (internal-file|external-file) > - -<!ELEMENT note (#PCDATA) > -<!ATTLIST note - xml:lang CDATA #IMPLIED - priority (1|2|3|4|5|6|7|8|9|10) "1" - from CDATA #IMPLIED -> - -<!ELEMENT prop-group (prop)+ > -<!ATTLIST prop-group - name CDATA #IMPLIED -> - -<!ELEMENT prop (#PCDATA) > -<!ATTLIST prop - prop-type CDATA #REQUIRED - xml:lang CDATA #IMPLIED -> - -<!ELEMENT context-group (context)+ > -<!ATTLIST context-group - name CDATA #REQUIRED - crc NMTOKEN #IMPLIED -> - -<!-- Processing instructions related to <context-group>: - -<?xliff-show-context-group name='value' ?> - -Indicates that any <context-group> element with a name set to 'value' should be -displayed to the end-user. - ---> - -<!ELEMENT context (#PCDATA) > -<!ATTLIST context - context-type CDATA #REQUIRED - match-mandatory (yes|no) "no" - crc NMTOKEN #IMPLIED -> - -<!-- Processing instructions related to <context>: - -<?xliff-show-context context-type='value' ?> - -Indicates that any <context> element with a context-type set to 'value' should -be displayed to the end-user. - ---> - -<!ELEMENT phase-group (phase)+ > - -<!ELEMENT phase (note)* > -<!ATTLIST phase - phase-name CDATA #REQUIRED - process-name CDATA #REQUIRED - company-name CDATA #IMPLIED - tool CDATA #IMPLIED - date CDATA #IMPLIED - job-id CDATA #IMPLIED - contact-name CDATA #IMPLIED - contact-email CDATA #IMPLIED - contact-phone CDATA #IMPLIED -> - -<!ELEMENT count-group (count)* > -<!ATTLIST count-group - name CDATA #REQUIRED -> - -<!ELEMENT count (#PCDATA) > -<!ATTLIST count - count-type CDATA #IMPLIED - unit CDATA #IMPLIED -> - -<!ELEMENT body (group|trans-unit|bin-unit)* > - -<!ELEMENT group ((context-group*,count-group*,prop-group*,note*),(group|trans-unit|bin-unit)*) -> -<!ATTLIST group - id NMTOKEN #IMPLIED - datatype CDATA #IMPLIED - xml:space (default|preserve) "default" - ts CDATA #IMPLIED - restype CDATA #IMPLIED - resname CDATA #IMPLIED - extradata CDATA #IMPLIED - extype CDATA #IMPLIED - help-id NMTOKEN #IMPLIED - menu CDATA #IMPLIED - menu-option CDATA #IMPLIED - menu-name CDATA #IMPLIED - coord CDATA #IMPLIED - font CDATA #IMPLIED - css-style CDATA #IMPLIED - style NMTOKEN #IMPLIED - exstyle NMTOKEN #IMPLIED -> - -<!ELEMENT trans-unit (source,target?,(count-group|note|context-group|prop-group|alt-trans)*) > -<!ATTLIST trans-unit - id NMTOKEN #REQUIRED - approved (yes|no) #IMPLIED - translate (yes|no) "yes" - reformat (yes|no) "yes" - xml:space (default|preserve) "default" - datatype CDATA #IMPLIED - ts CDATA #IMPLIED - restype CDATA #IMPLIED - resname CDATA #IMPLIED - extradata CDATA #IMPLIED - extype CDATA #IMPLIED - help-id NMTOKEN #IMPLIED - menu CDATA #IMPLIED - menu-option CDATA #IMPLIED - menu-name CDATA #IMPLIED - coord CDATA #IMPLIED - font CDATA #IMPLIED - css-style CDATA #IMPLIED - style NMTOKEN #IMPLIED - exstyle NMTOKEN #IMPLIED - size-unit CDATA #IMPLIED - maxwidth NMTOKEN #IMPLIED - minwidth NMTOKEN #IMPLIED - maxheight NMTOKEN #IMPLIED - minheight NMTOKEN #IMPLIED - maxbytes NMTOKEN #IMPLIED - minbytes NMTOKEN #IMPLIED - charclass CDATA #IMPLIED - phase-name CDATA #IMPLIED -> -<!-- size-unit: char|byte|pixel|glyph|dlgunit default='pixel' --> - -<!ELEMENT source (%TextContent;)* > -<!ATTLIST source - xml:lang CDATA #IMPLIED - ts CDATA #IMPLIED -> -<!-- coord = "x;y;cx;cy" - font= "fontname[;size[;weight]]" ---> - -<!ELEMENT target (%TextContent;)* > -<!ATTLIST target - state NMTOKEN #IMPLIED - phase-name NMTOKEN #IMPLIED - xml:lang CDATA #IMPLIED - ts CDATA #IMPLIED - restype CDATA #IMPLIED - resname CDATA #IMPLIED - coord CDATA #IMPLIED - font CDATA #IMPLIED - css-style CDATA #IMPLIED - style NMTOKEN #IMPLIED - exstyle NMTOKEN #IMPLIED -> - -<!ELEMENT alt-trans (source?,target+,(note|context-group|prop-group)*) > -<!ATTLIST alt-trans - match-quality CDATA #IMPLIED - tool CDATA #IMPLIED - crc NMTOKEN #IMPLIED - xml:lang CDATA #IMPLIED - origin CDATA #IMPLIED - datatype CDATA #IMPLIED - xml:space (default|preserve) "default" - ts CDATA #IMPLIED - restype CDATA #IMPLIED - resname CDATA #IMPLIED - extradata CDATA #IMPLIED - extype CDATA #IMPLIED - help-id NMTOKEN #IMPLIED - menu CDATA #IMPLIED - menu-option CDATA #IMPLIED - menu-name CDATA #IMPLIED - coord CDATA #IMPLIED - font CDATA #IMPLIED - css-style CDATA #IMPLIED - style NMTOKEN #IMPLIED - exstyle NMTOKEN #IMPLIED -> - - -<!ELEMENT bin-unit (bin-source,bin-target?,(note|context-group|prop-group|trans-unit)*) > -<!ATTLIST bin-unit - id NMTOKEN #REQUIRED - mime-type NMTOKEN #REQUIRED - approved (yes|no) #IMPLIED - translate (yes|no) "yes" - reformat (yes|no) "yes" - ts CDATA #IMPLIED - restype CDATA #IMPLIED - resname CDATA #IMPLIED - phase-name CDATA #IMPLIED -> - -<!ELEMENT bin-source (internal-file|external-file) > -<!ATTLIST bin-source - ts CDATA #IMPLIED -> - -<!ELEMENT bin-target (internal-file|external-file) > -<!ATTLIST bin-target - mime-type NMTOKEN #IMPLIED - ts CDATA #IMPLIED - state NMTOKEN #IMPLIED - phase-name NMTOKEN #IMPLIED - restype CDATA #IMPLIED - resname CDATA #IMPLIED -> - - - -<!-- ***************************************************************** --> -<!-- In-Line Elements --> -<!-- ***************************************************************** --> - -<!ELEMENT g (%TextContent;)* > -<!ATTLIST g - id CDATA #REQUIRED - ctype CDATA #IMPLIED - clone (yes|no) "yes" - ts CDATA #IMPLIED -> - -<!ELEMENT x EMPTY > -<!ATTLIST x - id CDATA #REQUIRED - ctype CDATA #IMPLIED - clone (yes|no) "yes" - ts CDATA #IMPLIED -> - -<!ELEMENT bx EMPTY > -<!ATTLIST bx - id CDATA #REQUIRED - rid NMTOKEN #IMPLIED - ctype CDATA #IMPLIED - clone (yes|no) "yes" - ts CDATA #IMPLIED -> - -<!ELEMENT ex EMPTY > -<!ATTLIST ex - id CDATA #REQUIRED - rid NMTOKEN #IMPLIED - ts CDATA #IMPLIED -> - -<!ELEMENT ph (%CodeContent;)* > -<!ATTLIST ph - id CDATA #REQUIRED - ctype CDATA #IMPLIED - ts CDATA #IMPLIED - crc NMTOKEN #IMPLIED - assoc CDATA #IMPLIED -> - -<!ELEMENT bpt (%CodeContent;)* > -<!ATTLIST bpt - id CDATA #REQUIRED - rid NMTOKEN #IMPLIED - ctype CDATA #IMPLIED - ts CDATA #IMPLIED - crc NMTOKEN #IMPLIED -> - -<!ELEMENT ept (%CodeContent;)* > -<!ATTLIST ept - id CDATA #REQUIRED - rid NMTOKEN #IMPLIED - ts CDATA #IMPLIED - crc NMTOKEN #IMPLIED -> - -<!ELEMENT it (%CodeContent;)* > -<!ATTLIST it - id CDATA #REQUIRED - pos (open|close) #REQUIRED - rid NMTOKEN #IMPLIED - ctype CDATA #IMPLIED - ts CDATA #IMPLIED - crc NMTOKEN #IMPLIED -> - -<!ELEMENT mrk (%TextContent;)* > -<!ATTLIST mrk - mtype CDATA #REQUIRED - mid NMTOKEN #IMPLIED - comment CDATA #IMPLIED - ts CDATA #IMPLIED -> - -<!ELEMENT sub (%TextContent;)* > -<!ATTLIST sub - datatype CDATA #IMPLIED - ctype CDATA #IMPLIED -> - - - -<!-- ***** End of DTD ************************************************ --> - - - diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/languageResolver/LanguageResolver.java b/l10ntools/java/l10nconv/java/com/sun/star/tooling/languageResolver/LanguageResolver.java deleted file mode 100755 index 4015c3acd2a7..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/languageResolver/LanguageResolver.java +++ /dev/null @@ -1,198 +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. - * - ************************************************************************/ -/* - * Created on 2005 - * by Christian Schmidt - */ -package com.sun.star.tooling.languageResolver; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.ListIterator; - -/** - * Translate language codes into another format - * between ISO, RFC3066 and numeric - * - * @author Christian Schmidt 2005 - * - */ -public class LanguageResolver { - private final static int ISO =2; - private final static int LANGID =0; - private final static int LANGNAME =1; - private final static int RFC3066 =3; - - ArrayList languages=new ArrayList(); - -// public static void main(String[] args){ -// try { -// LanguageResolver lr=new LanguageResolver(); -// } catch (IOException e) { -// // -// e.printStackTrace(); -// } -// } - - /** - * Create a new Instance of LanguageResolver - * - * @throws IOException - */ - public LanguageResolver() throws IOException{ - String lang = "com/sun/star/tooling/languageResolver/lang.map"; - ClassLoader cl = this.getClass().getClassLoader(); - InputStream in = cl.getResourceAsStream(lang); - BufferedReader languageTable= new BufferedReader(new InputStreamReader(in)); - - String line; - - while((line=(languageTable.readLine()))!=null){ - languages.add(line.split(",")); - } - } - /** - * Get the numeric value of the given ISO Language Code - * - * @param isoCode the ISO Language Code to find - * @return numeric value of the given isoCode - * @throws LanguageResolvingException if the Language ISO Code is not known - */ - public String getNrFromISO(String isoCode) throws LanguageResolvingException{ - if("".equals(isoCode)) return ""; - ListIterator iter=languages.listIterator(); - String[] line=new String[5]; - while(isoCode!="" && iter.hasNext()){ - line=(String[]) iter.next(); - if(line[ISO].equals(isoCode)) return line[LANGID]; - } - throw new LanguageResolvingException("Can not find ISO Code: "+isoCode ); - - } - - /** - * Get the ISO Language Code corresponding with the given Language ID - * - * @param ID the numeric language id to find - * @return the ISO Language Code corresponding with the given Language ID - * @throws LanguageResolvingException if the Language ID is not known - */ - public String getISOfromNr(String ID) throws LanguageResolvingException{ - if("".equals(ID)) return ""; - ListIterator iter=languages.listIterator(); - String[] line=new String[5]; - while(iter.hasNext()){ - line=(String[]) iter.next(); - if(line[LANGID].equals(ID)) return line[ISO]; - } - throw new LanguageResolvingException("Can not find Language Id: "+ID ); - } - - /** - * Get the RFC3066 value of the given ISO Language Code - * - * @param isoCode the ISO Language Code to find - * @return RFC3066 value of the given isoCode - * @throws LanguageResolvingException if the Language ISO Code is not known - */ - public String getRFCFromISO(String isoCode) throws LanguageResolvingException{ - if("".equals(isoCode)) return ""; - ListIterator iter=languages.listIterator(); - String[] line=new String[5]; - while(iter.hasNext()){ - line=(String[]) iter.next(); - if(line[ISO].equals(isoCode)) return line[RFC3066]; - } - throw new LanguageResolvingException("Can not find ISO Code: "+isoCode ); - } - - /** - * Get the ISO Language Code corresponding with the given RFC3066 code - * - * @param RFC RFC3066 language id to find - * @return the ISO Language Code corresponding with the given RFC3066 code - * @throws LanguageResolvingException if the RFC3066 code is not known - */ - public String getISOFromRFC(String RFC) throws LanguageResolvingException{ - if("".equals(RFC)) return ""; - ListIterator iter=languages.listIterator(); - String[] line=new String[5]; - while(iter.hasNext()){ - line=(String[]) iter.next(); - if(line[RFC3066].equals(RFC)) return line[ISO]; - } - throw new LanguageResolvingException("Can not find Language Id: "+RFC ); - } - - - /** - * This Exception is thrown if a Language Identfier is unknown - * - * @author Christian Schmidt 2005 - * - */ - public class LanguageResolvingException extends Exception { - - /** - * - */ - public LanguageResolvingException() { - super(); - // - } - - /** - * @param arg0 - */ - public LanguageResolvingException(String arg0) { - super(arg0); - // - } - - /** - * @param arg0 - * @param arg1 - */ - public LanguageResolvingException(String arg0, Throwable arg1) { - super(arg0, arg1); - // - } - - /** - * @param arg0 - */ - public LanguageResolvingException(Throwable arg0) { - super(arg0); - // - } - - } - -} diff --git a/l10ntools/java/l10nconv/java/com/sun/star/tooling/languageResolver/lang.map b/l10ntools/java/l10nconv/java/com/sun/star/tooling/languageResolver/lang.map deleted file mode 100755 index a43e8f5e0218..000000000000 --- a/l10ntools/java/l10nconv/java/com/sun/star/tooling/languageResolver/lang.map +++ /dev/null @@ -1,41 +0,0 @@ -1,English,en-US,en-US,1033 -3,Portuguese,pt,pt-PT,2070 -30,Greek,el,el-GR,1032 -33,French,fr,fr-FR,1036 -35,Finnish,fi,fi-FI,1035 -39,Italian,it,it-IT,1040 -43,Slowak,sk,sk-SK,1051 -46,Swedish,sv,sv-SE,1053 -48,Polish,pl,pl-PL,1045 -55,Portuguese (Brasil),pt-BR,pt-BR,2070 -82,Korean,ko,ko-KR,1042 -88,Chinese (traditional),zh-TW,zh-TW,1028 -96,Arabic,ar,,1025 -97,Hebrew,he,he-IL,1037 -7,Russian,ru,ru-RU,1049 -31,Dutch,nl,nl-NL,1043 -34,Spanish,es,es-ES,1034 -36,Hungarian,hu,hu-HU,1038 -42,Czech,cs,cs-CZ,1029 -45,Danish,da,da-DK,1030 -47,Norwegian (Bokmal),nb,nb-NB,1044 -49,German,de,de-DE,1031 -81,Japanese,ja,ja-JP,1041 -86,Chinese (simple),zh-CN,zh-CN,2052 -90,Turkish,tr,tr-TR,1055 -37,Catalan,ca,, -66,Thai,th,th-TH, -91,Hindi,hi-IN,hi-IN, -77,Estonian,et,et, -50,Slovenian,sl,sl, -79,Norwegian Nynorsk,nn,nn-NN, -53,Welsh,cy,cy, -27,Afrikaans,af,af-ZA, -38,Galician,gl-ES,gl-ES, -58,Lithuanian,lt,lt-LT, -29,Tswana,tn,tn-TN, -76,Khmer ( Cambodia ),km,km, -26,Northern Sotho,ns,ns-ZA, -28,Zulu,zu,zu-ZA, -10,Basque,eu,eu-ES, -93,Kannada,kn,kn-KN,
\ No newline at end of file |