output language in (Word) XSL FO

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1151511 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sergey Vladimirov 2011-07-27 15:57:45 +00:00
parent 32dbdf8071
commit 2654b604ed
3 changed files with 34 additions and 1 deletions

View File

@ -23,6 +23,9 @@ import java.io.InputStream;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.HWPFDocumentCore; import org.apache.poi.hwpf.HWPFDocumentCore;
import org.apache.poi.hwpf.HWPFOldDocument; import org.apache.poi.hwpf.HWPFOldDocument;
@ -46,6 +49,9 @@ public class AbstractWordUtils
{ {
static final String EMPTY = ""; static final String EMPTY = "";
private static final POILogger logger = POILogFactory
.getLogger( AbstractWordUtils.class );
public static final float TWIPS_PER_INCH = 1440.0f; public static final float TWIPS_PER_INCH = 1440.0f;
public static final int TWIPS_PER_PT = 20; public static final int TWIPS_PER_PT = 20;
@ -377,6 +383,23 @@ public class AbstractWordUtils
return ""; return "";
} }
public static String getLanguage( int languageCode )
{
switch ( languageCode )
{
case 1033:
return "en-us";
case 1049:
return "ru-ru";
case 2057:
return "en-uk";
default:
logger.log( POILogger.WARN, "Uknown or unmapped language code: ",
Integer.valueOf( languageCode ) );
return "";
}
}
public static String getListItemNumberLabel( int number, int format ) public static String getListItemNumberLabel( int number, int format )
{ {

View File

@ -74,6 +74,12 @@ public class WordToFoUtils extends AbstractWordUtils
{ {
inline.setAttribute( "color", getColor24( characterRun.getIco24() ) ); inline.setAttribute( "color", getColor24( characterRun.getIco24() ) );
} }
if ( characterRun.getLanguageCode() != 0 )
{
final String language = getLanguage( characterRun.getLanguageCode() );
if ( isNotEmpty( language ) )
inline.setAttribute( "language", language );
}
if ( characterRun.isCapitalized() ) if ( characterRun.isCapitalized() )
{ {
inline.setAttribute( "text-transform", "uppercase" ); inline.setAttribute( "text-transform", "uppercase" );
@ -273,7 +279,7 @@ public class WordToFoUtils extends AbstractWordUtils
graphicElement.setAttribute( "clip", "rect(" + rectTop + "pt, " graphicElement.setAttribute( "clip", "rect(" + rectTop + "pt, "
+ rectRight + "pt, " + rectBottom + "pt, " + rectLeft + rectRight + "pt, " + rectBottom + "pt, " + rectLeft
+ "pt)" ); + "pt)" );
graphicElement.setAttribute( "oveerflow", "hidden" ); graphicElement.setAttribute( "overflow", "hidden" );
} }
} }

View File

@ -620,6 +620,10 @@ public final class CharacterRun
return _props.getBrc(); return _props.getBrc();
} }
public int getLanguageCode() {
return _props.getLidDefault();
}
public String toString() { public String toString() {
String text = text(); String text = text();
return "CharacterRun of " + text.length() + " characters - " + text; return "CharacterRun of " + text.length() + " characters - " + text;