[hmath-commits] org.hmath.server/WEB-INF/src/org/hartmath/server/macro STableMacro.java,NONE,1.1
Status: Pre-Alpha
Brought to you by:
jsurfer
|
From: Klaus H. <js...@us...> - 2004-04-02 18:28:42
|
Update of /cvsroot/hmath/org.hmath.server/WEB-INF/src/org/hartmath/server/macro In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10254/WEB-INF/src/org/hartmath/server/macro Added Files: STableMacro.java Log Message: misc changes --- NEW FILE: STableMacro.java --- /* * This file is part of "SnipSnap Radeox Rendering Engine". * * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel * All Rights Reserved. * * Please visit http://radeox.org/ for updates and contact. * * --LICENSE NOTICE-- * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * --LICENSE NOTICE-- */ package org.hartmath.server.macro; import java.io.IOException; import java.io.Writer; import org.hartmath.server.filter.INoParserBodyFilterMacro; import org.hartmath.server.macro.table.STableBuilder; import org.hartmath.server.macro.table.Table; import org.radeox.api.engine.context.RenderContext; import org.radeox.macro.BaseLocaleMacro; import org.radeox.macro.parameter.MacroParameter; /* * Macro for defining and displaying tables. The rows of the table are * devided by newlins and the columns are divided by pipe symbols "|". * The first line of the table is rendered as column headers. * {table} * A|B|C * 1|2|3 * {table} * * @author stephan * @team sonicteam * @version $Id: STableMacro.java,v 1.1 2004/04/02 18:16:25 jsurfer Exp $ */ public class STableMacro extends BaseLocaleMacro implements INoParserBodyFilterMacro { private String[] paramDescription = {}; public String[] getParamDescription() { return paramDescription; } public String getLocaleKey() { return "macro.stable"; } public void execute(Writer writer, MacroParameter params) throws IllegalArgumentException, IOException { String content = params.getContent(); if (null == content) throw new IllegalArgumentException("STableMacro: missing table content"); // content = content.trim(); int index = content.indexOf('\n'); if (index>=0) { content = content.substring(index+1); } RenderContext context = params.getContext(); Table table = STableBuilder.build(content, context); table.calc(); // calculate macros like =SUM(A1:A3) table.appendTo(writer); return; } } |