public FormatRecord(int indexCode, String fs) { field_1_index_code = indexCode; field_4_formatstring = fs; field_3_hasMultibyte = StringUtil.hasMultibyte(fs); }
/** * Sets the string represented by this record. */ public void setString(String string) { _text = string; _is16bitUnicode = StringUtil.hasMultibyte(string); }
/** * Name of the original comment author * * @param author the name of the original author of the comment */ public void setAuthor(String author) { field_6_author = author; field_5_hasMultibyte = StringUtil.hasMultibyte(author); }
/** sets the name of the named range * @param name named range name */ public void setNameText(String name){ field_12_name_text = name; field_11_nameIsMultibyte = StringUtil.hasMultibyte(name); }
@Override protected int getDataSize() { if (_name == null) { return BASE_SIZE; } return BASE_SIZE + 1 // unicode flag + _name.length() * (StringUtil.hasMultibyte(_name) ? 2 : 1); }
protected int getDataSize() { int size = 16; // 5 shorts + 6 bytes int fontNameLen = field_11_font_name.length(); if (fontNameLen < 1) { return size; } boolean hasMultibyte = StringUtil.hasMultibyte(field_11_font_name); return size + fontNameLen * (hasMultibyte ? 2 : 1); }
/** * @return the number of bytes that would be written by {@link #writeUnicodeString(LittleEndianOutput, String)} */ public static int getEncodedSize(String value) { int result = 2 + 1; result += value.length() * (StringUtil.hasMultibyte(value) ? 2 : 1); return result; }
@Override protected int getDataSize() { return 18 // 4 shorts + 1 long + 2 spurious 'nul's + (StringUtil.hasMultibyte(field_6_name_text) ? field_6_name_text.length()*2 : field_6_name_text.length()) + (StringUtil.hasMultibyte(field_7_comment_text) ? field_7_comment_text.length()*2 : field_7_comment_text.length()); }
/** * Set the text field for the SeriesText record. */ public void setText(String text) { if (text.length() > MAX_LEN) { throw new IllegalArgumentException("Text is too long (" + text.length() + ">" + MAX_LEN + ")"); } field_4_text = text; is16bit = StringUtil.hasMultibyte(text); } }
/** * set the username for the user that created the report. HSSF uses the * logged in user. * * @param username of the user who is logged in (probably "tomcat" or "apache") */ public void setUsername(String username) { boolean is16bit = StringUtil.hasMultibyte(username); int encodedByteCount = 3 + username.length() * (is16bit ? 2 : 1); int paddingSize = DATA_SIZE - encodedByteCount; if (paddingSize < 0) { throw new IllegalArgumentException("Name is too long: " + username); } field_1_username = username; }
/** * Create a StringPtg from a string representation of the number Number * format is not checked, it is expected to be validated in the parser that * calls this method. * * @param value : * String representation of a floating point number */ public StringPtg(String value) { if (value.length() > 255) { throw new IllegalArgumentException( "String literals in formulas can't be bigger than 255 characters ASCII"); } _is16bitUnicode = StringUtil.hasMultibyte(value); field_3_string = value; }
/** * set the style's name * @param name of the style */ public void setName(String name) { field_4_name = name; field_3_stringHasMultibyte = StringUtil.hasMultibyte(name); field_1_xf_index = isBuiltinFlag.clear(field_1_xf_index); }
/** * Set the sheetname for this sheet. (this appears in the tabs at the bottom) * @param sheetName the name of the sheet * @see org.apache.poi.ss.util.WorkbookUtil#createSafeSheetName(String nameProposal) * for a safe way to create valid names * @throws IllegalArgumentException if sheet name will cause excel to crash. */ public void setSheetname(String sheetName) { WorkbookUtil.validateSheetName(sheetName); field_5_sheetname = sheetName; field_4_isMultibyteUnicode = StringUtil.hasMultibyte(sheetName) ? 1 : 0; }
private static int getUnicodeStringSize(UnicodeString us) { String str = us.getString(); return 3 + str.length() * (StringUtil.hasMultibyte(str) ? 2 : 1); }
/** * set the footer string * * @param text string to display */ public final void setText(String text) { if (text == null) { throw new IllegalArgumentException("text must not be null"); } field_2_hasMultibyte = StringUtil.hasMultibyte(text); field_3_text = text; // Check it'll fit into the space in the record if (getDataSize() > RecordInputStream.MAX_RECORD_DATA_SIZE) { throw new IllegalArgumentException("Header/Footer string too long (limit is " + RecordInputStream.MAX_RECORD_DATA_SIZE + " bytes)"); } }
public void serialize(LittleEndianOutput out) { String username = getUsername(); boolean is16bit = StringUtil.hasMultibyte(username); out.writeShort(username.length()); out.writeByte(is16bit ? 0x01 : 0x00); if (is16bit) { StringUtil.putUnicodeLE(username, out); } else { StringUtil.putCompressedUnicode(username, out); } int encodedByteCount = 3 + username.length() * (is16bit ? 2 : 1); int paddingSize = DATA_SIZE - encodedByteCount; out.write(PADDING, 0, paddingSize); }
/** * OutputStream <tt>out</tt> will get: * <ol> * <li>ushort nChars</li> * <li>byte is16BitFlag</li> * <li>byte[]/char[] characterData</li> * </ol> * For this encoding, the is16BitFlag is always present even if nChars==0. */ public static void writeUnicodeString(LittleEndianOutput out, String value) { int nChars = value.length(); out.writeShort(nChars); boolean is16Bit = hasMultibyte(value); out.writeByte(is16Bit ? 0x01 : 0x00); if (is16Bit) { putUnicodeLE(value, out); } else { putCompressedUnicode(value, out); } }
/** * OutputStream <tt>out</tt> will get: * <ol> * <li>byte is16BitFlag</li> * <li>byte[]/char[] characterData</li> * </ol> * For this encoding, the is16BitFlag is always present even if nChars==0. * <br> * This method should be used when the nChars field is <em>not</em> stored * as a ushort immediately before the is16BitFlag. Otherwise, {@link * #writeUnicodeString(LittleEndianOutput, String)} can be used. */ public static void writeUnicodeStringFlagAndData(LittleEndianOutput out, String value) { boolean is16Bit = hasMultibyte(value); out.writeByte(is16Bit ? 0x01 : 0x00); if (is16Bit) { putUnicodeLE(value, out); } else { putCompressedUnicode(value, out); } }
@Override public void serialize(final LittleEndianOutput out) { final int field_4_name_length = field_6_name_text.length(); final int field_5_comment_length = field_7_comment_text.length(); out.writeShort(field_1_record_type); out.writeShort(field_2_frt_cell_ref_flag); out.writeLong(field_3_reserved); out.writeShort(field_4_name_length); out.writeShort(field_5_comment_length); boolean isNameMultiByte = StringUtil.hasMultibyte(field_6_name_text); out.writeByte(isNameMultiByte ? 1 : 0); if (isNameMultiByte) { StringUtil.putUnicodeLE(field_6_name_text, out); } else { StringUtil.putCompressedUnicode(field_6_name_text, out); } boolean isCommentMultiByte = StringUtil.hasMultibyte(field_7_comment_text); out.writeByte(isCommentMultiByte ? 1 : 0); if (isCommentMultiByte) { StringUtil.putUnicodeLE(field_7_comment_text, out); } else { StringUtil.putCompressedUnicode(field_7_comment_text, out); } }
public void serialize(LittleEndianOutput out) { out.writeShort(getFontHeight()); out.writeShort(getAttributes()); out.writeShort(getColorPaletteIndex()); out.writeShort(getBoldWeight()); out.writeShort(getSuperSubScript()); out.writeByte(getUnderline()); out.writeByte(getFamily()); out.writeByte(getCharset()); out.writeByte(field_9_zero); int fontNameLen = field_11_font_name.length(); out.writeByte(fontNameLen); boolean hasMultibyte = StringUtil.hasMultibyte(field_11_font_name); out.writeByte(hasMultibyte ? 0x01 : 0x00); if (fontNameLen > 0) { if (hasMultibyte) { StringUtil.putUnicodeLE(field_11_font_name, out); } else { StringUtil.putCompressedUnicode(field_11_font_name, out); } } } protected int getDataSize() {