Description: An element in the Font Table
REFERENCE: PG 315 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)
@author Andrew C. Oliver (acoliver at apache dot org) @version 2.0-pre
12641265126612671268126912701271127212731274127512761277
* bold weight = 0x190<P> * Font Name Length = 5 <P> * Font Name = Arial <P> */ private static FontRecord createFont() { FontRecord retval = new FontRecord(); retval.setFontHeight(( short ) 0xc8); retval.setAttributes(( short ) 0x0); retval.setColorPaletteIndex(( short ) 0x7fff); retval.setBoldWeight(( short ) 0x190); retval.setFontName("Arial"); return retval; }
10061007100810091010101110121013101410151016
* @return new font object */ public HSSFFont createFont() { FontRecord font = workbook.createNewFont(); short fontindex = (short) (getNumberOfFonts() - 1); if (fontindex > 3) { fontindex++; // THERE IS NO FOUR!!
10761077107810791080108110821083108410851086
Short sIdx = Short.valueOf(idx); if(fonts.containsKey(sIdx)) { return (HSSFFont)fonts.get(sIdx); } FontRecord font = workbook.getFontRecordAt(idx); HSSFFont retval = new HSSFFont(idx, font); fonts.put(sIdx, retval); return retval; }
474475476477478479480481482483
if (index > (numfonts - 1)) { throw new ArrayIndexOutOfBoundsException( "There are only " + numfonts + " font records, you asked for " + idx); } FontRecord retval = ( FontRecord ) records.get((records.getFontpos() - (numfonts - 1)) + index); return retval; }
485486487488489490491492493494495
/** * Retrieves the index of the given font */ public int getFontIndex(FontRecord font) { for(int i=0; i<=numfonts; i++) { FontRecord thisFont = ( FontRecord ) records.get((records.getFontpos() - (numfonts - 1)) + i); if(thisFont == font) { // There is no 4! if(i > 3) { return (i+1);
507508509510511512513514515516517
* * @return FontRecord that was just created */ public FontRecord createNewFont() { FontRecord rec = createFont(); records.add(records.getFontpos()+1, rec); records.setFontpos( records.getFontpos() + 1 ); numfonts++; return rec;
12621263126412651266126712681269127012711272127312741275
831832833834835836837838839840841842
short fmt = (short)_workbook.createFormat(source.getDataFormatString() ); setDataFormat(fmt); // Finally we need to clone the font, // and update the format record for this FontRecord fr = _workbook.createNewFont(); fr.cloneStyleFrom( source._workbook.getFontRecordAt( source.getFontIndex() ) );
767778798081828384858687
// of an earlier one int earlierDuplicate = -1; for(int j=0; j<i && earlierDuplicate == -1; j++) { if(j == 4) continue; FontRecord frCheck = workbook.getWorkbook().getFontRecordAt(j); if(frCheck.sameProperties(frecs[i])) { earlierDuplicate = j; } } // If we got a duplicate, mark it as such
102310241025102610271028102910301031103210331034
); setDataFormat(fmt); // Finally we need to clone the font, // and update the format record for this FontRecord fr = workbook.createNewFont(); fr.cloneStyleFrom( source.workbook.getFontRecordAt( source.getFontIndex() ) );