// (c) Asko Soukka, Matti Katila package gzz.modules.pp; import gzz.*; import gzz.vob.*; import gzz.zzutil.*; import gzz.view.*; public class PPCellView extends LinebrokenCellContentView { public PPCellView(TextStyle style, String widthString) { super(style, widthString); } public void getSize(Cell c, float scale, ViewContext context, float[] out) { String s; if(c != null) s = Containment.getContainedText(c); else s = widthString; /** * Width of LinebrokenCellContentView is the * width of its longest line. */ float w = style.getWidth(s, scale); int linebreak = s.indexOf('\n'); if (linebreak != -1) { w = style.getWidth(s.substring(0, linebreak), scale); int anotherLinebreak = s.indexOf('\n', linebreak+1); while (anotherLinebreak != -1) { float anotherWidth = style.getWidth(s.substring(linebreak+1, anotherLinebreak), scale); if (w < anotherWidth) w = anotherWidth; linebreak = anotherLinebreak; anotherLinebreak = s.indexOf('\n', linebreak+1); } float anotherWidth = style.getWidth(s.substring(linebreak+1, s.length()), scale); if (w < anotherWidth) w = anotherWidth; } float h; if(c != null) h = getHeight(c, w, scale); else h = style.getHeight(scale); out[0] = w/scale; out[1] = h/scale; } }