/* JSPWiki - a JSP-based WikiWiki clone. Copyright (C) 2002 Janne Jalkanen (Janne.Jalkanen@iki.fi) This program 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 program 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 program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package brushed.jspwiki.visioplugin; import java.util.*; import com.ecyrd.jspwiki.*; import com.ecyrd.jspwiki.plugin.*; import com.ecyrd.jspwiki.attachment.AttachmentManager; import com.ecyrd.jspwiki.attachment.Attachment; import com.ecyrd.jspwiki.providers.ProviderException; /** * Provides an visio plugin for inline expansion of a Microsoft VISIO attachment * Source code inspired by the JSPWiki Image plugin. * * @author Dirk Frederickx * @since 2.1.86 */ public class Visio implements WikiPlugin { public static final String PARAM_SRC = "src"; public static final String PARAM_HEIGHT = "height"; public static final String PARAM_WIDTH = "width"; public static final String PARAM_STYLE = "style"; public static final String PARAM_BC = "backColor"; public static final String PARAM_AE = "alertsEnabled"; public static final String PARAM_CME = "contextMenuEnabled"; public static final String PARAM_GV = "gridVisible"; public static final String PARAM_HQR = "highQualityRender"; public static final String PARAM_PC = "pageColor"; public static final String PARAM_PV = "pageVisible"; public static final String PARAM_PTV = "pageTabsVisible"; public static final String PARAM_PDE = "propertyDialogEnabled"; public static final String PARAM_SV = "scrollbarsVisible"; public static final String PARAM_SGV = "sizeGripVisible"; public static final String PARAM_TV = "toolbarVisible"; public static final String PARAM_CPI = "currentPageIndex"; public static final String PARAM_ZM = "zoom"; /** * This method is used to clean away things like quotation marks which * a malicious user could use to stop processing and insert javascript. */ private static final String getCleanParameter( Map params, String paramId ) { return TextUtil.replaceEntities( (String) params.get( paramId ) ); } public String execute( WikiContext context, Map params ) throws PluginException { WikiEngine engine = context.getEngine(); String src = getCleanParameter( params, PARAM_SRC ); String ht = getCleanParameter( params, PARAM_HEIGHT ); String wt = getCleanParameter( params, PARAM_WIDTH ); String style = getCleanParameter( params, PARAM_STYLE ); String bc = getCleanParameter( params, PARAM_BC ); String ae = getCleanParameter( params, PARAM_AE ); String cme = getCleanParameter( params, PARAM_CME ); String gv = getCleanParameter( params, PARAM_GV ); String hqr = getCleanParameter( params, PARAM_HQR ); String pc = getCleanParameter( params, PARAM_PC ); String pv = getCleanParameter( params, PARAM_PV ); String ptv = getCleanParameter( params, PARAM_PTV ); String pde = getCleanParameter( params, PARAM_PDE ); String sv = getCleanParameter( params, PARAM_SV ); String sgv = getCleanParameter( params, PARAM_SGV ); String tv = getCleanParameter( params, PARAM_TV ); String cpi = getCleanParameter( params, PARAM_CPI ); String zm = getCleanParameter( params, PARAM_ZM ); if( src == null ) { throw new PluginException("Parameter 'src' is required for Visio plugin"); } try { AttachmentManager mgr = engine.getAttachmentManager(); Attachment att = mgr.getAttachmentInfo( context, src ); if( att != null ) { src = engine.getAttachmentURL(att.getName()); } } catch( ProviderException e ) { throw new PluginException( "Attachment info failed: "+e.getMessage() ); } StringBuffer result = new StringBuffer(); result.append( "
\n" ); //default values if (ht == null ) ht = "100%"; if (wt == null ) wt = "100%"; //if (bc == null ) bc = "16777200"; if (ae == null ) ae = "1"; if (cme == null ) cme = "1"; if (gv == null ) gv = "0"; if (hqr == null ) hqr = "1"; //if (pc == null ) pc = "16777215"; if (pv == null ) pv = "1"; if (ptv == null ) ptv = "0"; if (pde == null ) pde = "1"; if (sv == null ) sv = "0"; if (sgv == null ) sgv = "1"; if (tv == null ) tv = "0"; if (cpi == null ) cpi = "0"; if (zm == null ) zm = "-1"; result.append( "\n"); result.append( " \n" ); if( bc != null) { result.append( " \n" ); } result.append( " \n" ); result.append( " \n" ); result.append( " \n" ); result.append( " \n" ); if( pc != null) { result.append( " \n" ); } result.append( " \n" ); result.append( " \n" ); result.append( " \n" ); result.append( " \n" ); result.append( " \n" ); result.append( " \n" ); result.append( " \n" ); result.append( " \n" ); result.append( "The JSPWiki Visio plugin for " + src + " only works with Internet Explorer and Microsoft Visio Viewer 2003 available here.\n" ); result.append( " \n" ); result.append( "
\n" ); //added div closure return result.toString(); } }