ParagraphStyleHandler extends DefaultStyleHandler { public String getLanguage(ScriptType type) { String language = null; TextProperties textProperties = getTextPropertiesForRead(); if (textProperties != null) { language = textProperties.getLanguage(type); } if (language != null && language.length() > 0) { return language; } boolean isDefault = isUseDefaultStyle; OdfStyleBase parentStyle = null; if (!isDefault) { parentStyle = getParentStyle((OdfStyle) getCurrentUsedStyle()); } while ((!isDefault) && (parentStyle != null)) { TextProperties parentStyleSetting = TextProperties.getTextProperties(parentStyle); language = parentStyleSetting.getLanguage(type); if (language != null && language.length() > 0) { return language; } if (parentStyle instanceof OdfDefaultStyle) { isDefault = true; } else { parentStyle = getParentStyle((OdfStyle) parentStyle); } } if (!isDefault) { OdfDefaultStyle defaultStyle = getParagraphDefaultStyle(); TextProperties defaultStyleSetting = TextProperties.getTextProperties(defaultStyle); language = defaultStyleSetting.getLanguage(type); } return language; } ParagraphStyleHandler(Paragraph aParagraph); String getCountry(ScriptType type); Font getFont(ScriptType type); String getLanguage(ScriptType type); void setCountry(String country, ScriptType type); void setFont(Font font); void setFont(Font font, Locale language); void setLanguage(String language, ScriptType type); void setHorizontalAlignment(HorizontalAlignmentType alignType); HorizontalAlignmentType getHorizontalAlignment();  }
@Test public void testGetLanguage() { try { TextDocument doc = TextDocument.newTextDocument(); Paragraph paragraph = doc.addParagraph("paragraphTest"); ParagraphStyleHandler paragraphHandler = paragraph.getStyleHandler(); paragraphHandler.setLanguage("English", Document.ScriptType.WESTERN); String language = paragraphHandler.getLanguage(Document.ScriptType.WESTERN); Assert.assertEquals("English", language); } catch (Exception e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); Assert.fail(e.getMessage()); } }