docbook article support
Phil Chu <[email protected]> Thu, 24 Jul 2003 21:58:38 -0700
| Newsgroups | gmane.text.xml.jfor.devel |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format. --------------080205070704020108090906 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit I have jfor working with my docbook FO files by adding support for em units and proportional-column-widths. Only works with articles, not books, as the latter references the "body-start()" function. Appended/attached are the patched files and one new file. I'll put a copy of the jar on my web site if anyone wants to try it out. -Phil -- Phil Chu [email protected] http://www.technicat.com/ =================================================================== RCS file: /cvsroot/jfor/jfor/src/org/jfor/jfor/converter/Converter.java,v retrieving revision 1.15 diff -r1.15 Converter.java 62a63 > * @author Phil Chu [email protected] 272a274,276 > // Added by Phil Chu > // Postprocessing support for proportional-column-width > m_builders.add(new TableBodyBuilder(m_context)); Index: FoUnitsConverter.java =================================================================== RCS file: /cvsroot/jfor/jfor/src/org/jfor/jfor/converter/FoUnitsConverter.java,v retrieving revision 1.7 diff -r1.7 FoUnitsConverter.java 105a106,107 > // added by Phil Chu 7/24/03 > public static final float EM_TO_TWIPS = 12 * POINT_TO_TWIPS; 114a117,118 > // added by Phil Chu 7/24/03 > m_twipFactors.put("em",new Float(EM_TO_TWIPS)); Index: TableContext.java =================================================================== RCS file: /cvsroot/jfor/jfor/src/org/jfor/jfor/converter/TableContext.java,v retrieving revision 1.6 diff -r1.6 TableContext.java 2a3 > import java.util.regex.*; 93a95,96 > // added Phil Chu 7/24/03 > private Matcher m_matcher = Pattern.compile("proportional-column-width\\(([0-9]+)\\)").matcher(""); 121c124,153 < m_colWidths.add(new Float(FoUnitsConverter.getInstance().convertToTwips(strWidth))); --- > //Added by Phil Chu on 2003-7-24 > m_matcher.reset(strWidth); > if (m_matcher.find()) { > m_colWidths.add(new Integer(m_matcher.group(1))); > } else { > m_colWidths.add(new Float(FoUnitsConverter.getInstance().convertToTwips(strWidth))); > } > } > > //Added by Phil Chu on 2003-7-24 > void processColumnWidths() { > // get total number of proportional units > // and sum up existing absolute column widths (twips) > float pwidth=0.0f; // use float because we're going to make a ratio > float twips=0.0f; // twips already calculated > for (int i=0; i<m_colWidths.size(); ++i) { > if (Integer.class.isInstance(m_colWidths.get(i))) { > pwidth+=((Integer)m_colWidths.get(i)).intValue(); > } else { > twips+=((Float)m_colWidths.get(i)).floatValue(); > } > } > // replace each proportional-column-unit with a real width > // using a hardcoded total table width for now > float maxtwips = 7.5f*FoUnitsConverter.IN_TO_TWIPS; > for (int i=0; i<m_colWidths.size(); ++i) { > if (Integer.class.isInstance(m_colWidths.get(i))) { > m_colWidths.set(i,new Float(((Integer)m_colWidths.get(i)).intValue()/pwidth*(maxtwips-twips))); > } > } --------------080205070704020108090906 Content-Type: text/plain; name="TableBodyBuilder.java" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="TableBodyBuilder.java" package org.jfor.jfor.converter; import java.io.IOException; import org.xml.sax.Attributes; import org.jfor.jfor.rtflib.rtfdoc.*; /*----------------------------------------------------------------------------- * jfor - Open-Source XSL-FO to RTF converter - see www.jfor.org * * ==================================================================== * jfor Apache-Style Software License. * Copyright (c) 2002 by the jfor project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed * by the jfor project (http://www.jfor.org)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The name "jfor" must not be used to endorse * or promote products derived from this software without prior written * permission. For written permission, please contact [email protected]. * * 5. Products derived from this software may not be called "jfor", * nor may "jfor" appear in their name, without prior written * permission of [email protected]. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE JFOR PROJECT OR ITS CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * Contributor(s): -----------------------------------------------------------------------------*/ /** An IBuilder that handles fo:table-body * @author Phil Chu [email protected] */ //------------------------------------------------------------------------------ // $Id: // $Log: // //------------------------------------------------------------------------------ class TableBodyBuilder extends AbstractBuilder { private static final String TB = "fo:table-body"; TableBodyBuilder(BuilderContext ctx) { super(ctx); } /** called by Converter at the start of an element */ public void start(String rawName, Attributes attrs) throws IOException { // process proportional-column-widths m_context.getTableContext().processColumnWidths(); } /** called by Converter at the end of an element */ public void end() throws IOException { } /** return a TableBuilder for fo:table elements */ public IBuilder getBuilder(BuilderContext ctx,String rawName, Attributes atts) { if(rawName.equals(TB)) return new TableBodyBuilder(ctx); else return null; } } --------------080205070704020108090906-- ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01