/** * Creates a format tracking wrapper around the given listener, using * the {@link Locale#getDefault() default locale} for the formats. * * @param childListener the listener to be wrapped */ public FormatTrackingHSSFListener(HSSFListener childListener) { this(childListener, LocaleUtil.getUserLocale()); }
/** * Creates a formatter using the {@link Locale#getDefault() default locale}. */ public HSSFDataFormatter() { this(LocaleUtil.getUserLocale()); }
/** * Creates a new cell number formatter. * * @param format The format to parse. */ public CellNumberFormatter(String format) { this(LocaleUtil.getUserLocale(), format); }
/** Creates a new general formatter. */ public CellGeneralFormatter() { this(LocaleUtil.getUserLocale()); } /** Creates a new general formatter. */
/** * Creates a formatter using the {@link Locale#getDefault() default locale}. * * @param emulateCSV whether to emulate CSV output. */ public DataFormatter(boolean emulateCSV) { this(LocaleUtil.getUserLocale(), true, emulateCSV); }
/** * Creates a new date formatter with the given specification. * * @param format The format. */ public CellDateFormatter(String format) { this(LocaleUtil.getUserLocale(), format); }
/** * Create an object to represent a format part. * * @param desc The string to parse. */ public CellFormatPart(String desc) { this(LocaleUtil.getUserLocale(), desc); }
/** * Creates a new formatter object, storing the format in {@link #format}. * * @param format The format. */ public CellFormatter(String format) { this(LocaleUtil.getUserLocale(), format); }
/** * @return a calendar for the user locale and time zone */ public static Calendar getLocaleCalendar(TimeZone timeZone) { return Calendar.getInstance(timeZone, getUserLocale()); }
/** * Returns a {@link CellFormat} that applies the given format. Two calls * with the same format may or may not return the same object. * * @param format The format. * * @return A {@link CellFormat} that applies the given format. */ public static CellFormat getInstance(String format) { return getInstance(LocaleUtil.getUserLocale(), format); }
void checkForLocaleChange() { checkForLocaleChange(LocaleUtil.getUserLocale()); } void checkForLocaleChange(Locale newLocale) {
public ExcelStyleDateFormatter(String pattern) { super(processFormatPattern(pattern), LocaleUtil.getUserLocale()); }
/** * Shifts column range [firstShiftColumnIndex-lastShiftColumnIndex] step places to the left. * @param firstShiftColumnIndex the column to start shifting * @param lastShiftColumnIndex the column to end shifting * @param step length of the shifting step */ @Override public void shiftCellsLeft(int firstShiftColumnIndex, int lastShiftColumnIndex, int step) { if(step < 0) throw new IllegalArgumentException("Shifting step may not be negative "); if(firstShiftColumnIndex > lastShiftColumnIndex) throw new IllegalArgumentException(String.format(LocaleUtil.getUserLocale(), "Incorrect shifting range : %d-%d", firstShiftColumnIndex, lastShiftColumnIndex)); if(firstShiftColumnIndex - step < 0) throw new IllegalStateException("Column index less than zero : " + (Integer.valueOf(firstShiftColumnIndex + step)).toString()); for (int columnIndex = firstShiftColumnIndex; columnIndex <= lastShiftColumnIndex; columnIndex++){ HSSFCell cell = getCell(columnIndex); if(cell != null){ cells[columnIndex-step] = null; moveCell(cell, (short)(columnIndex-step)); } else cells[columnIndex-step] = null; } for (int columnIndex = lastShiftColumnIndex-step+1; columnIndex <= lastShiftColumnIndex; columnIndex++) cells[columnIndex] = null; } }
private void printShapeText(final TextShape<S,P> shape, final StringBuilder sb) { final List<P> paraList = shape.getTextParagraphs(); if (paraList.isEmpty()) { sb.append('\n'); return; } for (final P para : paraList) { for (final TextRun tr : para) { final String str = tr.getRawText().replace("\r", ""); final String newStr; switch (tr.getTextCap()) { case ALL: newStr = str.toUpperCase(LocaleUtil.getUserLocale()); break; case SMALL: newStr = str.toLowerCase(LocaleUtil.getUserLocale()); break; default: case NONE: newStr = str; break; } sb.append(newStr); } sb.append('\n'); } }
@Internal public String getRenderableText(final TextRun tr) { final String txtSpace = tr.getRawText().replace("\t", tab2space(tr)).replace('\u000b', '\n'); final Locale loc = LocaleUtil.getUserLocale(); switch (tr.getTextCap()) { case ALL: return txtSpace.toUpperCase(loc); case SMALL: return txtSpace.toLowerCase(loc); default: return txtSpace; } }
/** * Creates the Country record with the default country set to 1 * and current country set to 7 in case of russian locale ("ru_RU") and 1 otherwise */ private static CountryRecord createCountry() { CountryRecord retval = new CountryRecord(); retval.setDefaultCountry(( short ) 1); // from Russia with love ;) if ( "ru_RU".equals( LocaleUtil.getUserLocale().toString() ) ) { retval.setCurrentCountry(( short ) 7); } else { retval.setCurrentCountry(( short ) 1); } return retval; }
/** * Shifts column range [firstShiftColumnIndex-lastShiftColumnIndex] step places to the right. * @param firstShiftColumnIndex the column to start shifting * @param lastShiftColumnIndex the column to end shifting * @param step length of the shifting step */ @Override public void shiftCellsRight(int firstShiftColumnIndex, int lastShiftColumnIndex, int step) { if(step < 0) throw new IllegalArgumentException("Shifting step may not be negative "); if(firstShiftColumnIndex > lastShiftColumnIndex) throw new IllegalArgumentException(String.format(LocaleUtil.getUserLocale(), "Incorrect shifting range : %d-%d", firstShiftColumnIndex, lastShiftColumnIndex)); if(lastShiftColumnIndex + step + 1> cells.length) extend(lastShiftColumnIndex + step + 1); for (int columnIndex = lastShiftColumnIndex; columnIndex >= firstShiftColumnIndex; columnIndex--){ // process cells backwards, because of shifting HSSFCell cell = getCell(columnIndex); cells[columnIndex+step] = null; if(cell != null) moveCell(cell, (short)(columnIndex+step)); } for (int columnIndex = firstShiftColumnIndex; columnIndex <= firstShiftColumnIndex+step-1; columnIndex++) cells[columnIndex] = null; } private void extend(int newLenght){
/** * Append a new run of text. * * @return the new run of text. */ public XDDFTextRun appendRegularRun(String text) { CTRegularTextRun r = _p.addNewR(); r.setT(text); CTTextCharacterProperties rPr = r.addNewRPr(); rPr.setLang(LocaleUtil.getUserLocale().toLanguageTag()); XDDFTextRun run = new XDDFTextRun(r, this); _runs.add(run); return run; }
/** * Append a new text field. * * @return the new text field. */ public XDDFTextRun appendField(String id, String type, String text) { CTTextField f = _p.addNewFld(); f.setId(id); f.setType(type); f.setT(text); CTTextCharacterProperties rPr = f.addNewRPr(); rPr.setLang(LocaleUtil.getUserLocale().toLanguageTag()); XDDFTextRun run = new XDDFTextRun(f, this); _runs.add(run); return run; }
@Override public void setAuthor(final String author) { if (author == null) { throw new IllegalArgumentException("author must not be null"); } final CTCommentAuthorList list = authors.getCTCommentAuthorsList(); long maxId = -1; for (final CTCommentAuthor aut : list.getCmAuthorArray()) { maxId = Math.max(aut.getId(), maxId); if (author.equals(aut.getName())) { comment.setAuthorId(aut.getId()); return; } } // author not found -> add new author final CTCommentAuthor newAuthor = list.addNewCmAuthor(); newAuthor.setName(author); newAuthor.setId(maxId+1); newAuthor.setInitials(author.replaceAll( "\\s*(\\w)\\S*", "$1").toUpperCase(LocaleUtil.getUserLocale())); comment.setAuthorId(maxId+1); }