/** * Apply font selection algorithm to this Text, based on supplied PPr, RPr * (and docDefaults, Theme part etc). * * @param pPr * @param rPr * @param wmlText * @return */ public Object fontSelector(PPr pPr, RPr rPr, Text wmlText) { String text=null; if (wmlText==null) { log.debug("Null Text object"); } else { text = wmlText.getValue(); spacePreserve = (wmlText.getSpace()!=null) && (wmlText.getSpace().equals("preserve")); } return fontSelector( pPr, rPr, text); }
/** * Apply font selection algorithm to this Text, based on supplied PPr, RPr * (and docDefaults, Theme part etc). * * @param pPr * @param rPr * @param wmlText * @return */ public Object fontSelector(PPr pPr, RPr rPr, Text wmlText) { String text=null; if (wmlText==null) { log.debug("Null Text object"); } else { text = wmlText.getValue(); spacePreserve = (wmlText.getSpace()!=null) && (wmlText.getSpace().equals("preserve")); } return fontSelector( pPr, rPr, text); }
/** * Returns the text string of a run. * * @param run the run whose text to get. * @return String representation of the run. */ public static String getText(R run) { String result = ""; for (Object content : run.getContent()) { if (content instanceof JAXBElement) { JAXBElement element = (JAXBElement) content; if (element.getValue() instanceof Text) { Text textObj = (Text) element.getValue(); String text = textObj.getValue(); if (!"preserve".equals(textObj.getSpace())) { // trimming text if spaces are not to be preserved (simulates behavior of Word; LibreOffice seems // to ignore the "space" property and always preserves spaces) text = text.trim(); } result += text; }else if (element.getValue() instanceof R.Tab){ result += "\t"; } } else if (content instanceof Text) { result += ((Text) content).getValue(); } } return result; }