);
}
+ /**
+ * 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
* characters in the contents of this run when displayed in a document
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties;
import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture;
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.CTR;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBrClear;
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.STUnderline;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STVerticalAlignRun;
assertEquals(1, count);
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
public void testSetGetHighlight() throws IOException {