[github-86] expose language for Text Runs. Thanks to Geoff Baskwill. This closes #86
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1820242 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
859ce548a4
commit
d4df69570c
@ -248,6 +248,17 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the language tag associated with this run, if any.
|
||||||
|
*
|
||||||
|
* @return the language tag associated with this run, if any
|
||||||
|
*/
|
||||||
|
public String getLang() {
|
||||||
|
CTRPr pr = run.getRPr();
|
||||||
|
Object lang = pr == null || !pr.isSetLang() ? null : pr.getLang().getVal();
|
||||||
|
return (String)lang;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the bold property shall be applied to all non-complex script
|
* Whether the bold property shall be applied to all non-complex script
|
||||||
* characters in the contents of this run when displayed in a document
|
* characters in the contents of this run when displayed in a document
|
||||||
|
@ -18,6 +18,7 @@ package org.apache.poi.xwpf.usermodel;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -37,11 +38,14 @@ import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;
|
|||||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties;
|
import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties;
|
||||||
import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture;
|
import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBr;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBr;
|
||||||
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLang;
|
||||||
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLanguage;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBrClear;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBrClear;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STHighlightColor;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STHighlightColor;
|
||||||
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STLang;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STUnderline;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STUnderline;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STVerticalAlignRun;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STVerticalAlignRun;
|
||||||
@ -452,6 +456,21 @@ public class TestXWPFRun {
|
|||||||
assertEquals(1, count);
|
assertEquals(1, count);
|
||||||
sampleDoc.close();
|
sampleDoc.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetGetLang() throws IOException {
|
||||||
|
XWPFRun run = p.createRun();
|
||||||
|
assertNull(run.getLang());
|
||||||
|
|
||||||
|
run.getCTR().addNewRPr().addNewLang().setVal("en-CA");
|
||||||
|
assertEquals("en-CA", run.getLang());
|
||||||
|
|
||||||
|
run.getCTR().getRPr().getLang().setVal("fr-CA");
|
||||||
|
assertEquals("fr-CA", run.getLang());
|
||||||
|
|
||||||
|
run.getCTR().getRPr().getLang().setVal(null);
|
||||||
|
assertNull(run.getLang());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetGetHighlight() throws IOException {
|
public void testSetGetHighlight() throws IOException {
|
||||||
|
Loading…
Reference in New Issue
Block a user