From b934f1d65158159e2221807fc2863751e671f293 Mon Sep 17 00:00:00 2001 From: Peter Bernard West Date: Tue, 7 May 2002 06:00:08 +0000 Subject: [PATCH] Stripped-down experimental environment. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@194783 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/apps/AWTStarter.java | 165 ----- .../apache/fop/apps/CommandLineOptions.java | 630 ------------------ src/org/apache/fop/apps/PDFOutputHandler.java | 213 ------ src/org/apache/fop/apps/PrintStarter.java | 204 ------ src/org/apache/fop/apps/Starter.java | 52 -- src/org/apache/fop/apps/StreamRenderer.java | 315 --------- src/org/apache/fop/apps/TraxInputHandler.java | 111 --- src/org/apache/fop/apps/XSLTInputHandler.java | 126 ---- src/org/apache/fop/apps/XTDriver.java | 337 ---------- src/org/apache/fop/fo/flow/BasicLink.java | 137 ---- src/org/apache/fop/fo/flow/BidiOverride.java | 66 -- src/org/apache/fop/fo/flow/Block.java | 363 ---------- .../apache/fop/fo/flow/BlockContainer.java | 182 ----- src/org/apache/fop/fo/flow/Character.java | 165 ----- .../apache/fop/fo/flow/ExternalGraphic.java | 268 -------- src/org/apache/fop/fo/flow/Float.java | 47 -- src/org/apache/fop/fo/flow/Flow.java | 228 ------- src/org/apache/fop/fo/flow/Footnote.java | 123 ---- src/org/apache/fop/fo/flow/FootnoteBody.java | 84 --- .../fop/fo/flow/InitialPropertySet.java | 72 -- src/org/apache/fop/fo/flow/Inline.java | 107 --- .../apache/fop/fo/flow/InlineContainer.java | 70 -- .../fop/fo/flow/InstreamForeignObject.java | 299 --------- src/org/apache/fop/fo/flow/Leader.java | 212 ------ src/org/apache/fop/fo/flow/ListBlock.java | 181 ----- src/org/apache/fop/fo/flow/ListItem.java | 183 ----- src/org/apache/fop/fo/flow/ListItemBody.java | 78 --- src/org/apache/fop/fo/flow/ListItemLabel.java | 71 -- src/org/apache/fop/fo/flow/Marker.java | 89 --- src/org/apache/fop/fo/flow/MultiCase.java | 52 -- .../apache/fop/fo/flow/MultiProperties.java | 49 -- .../apache/fop/fo/flow/MultiPropertySet.java | 47 -- src/org/apache/fop/fo/flow/MultiSwitch.java | 50 -- src/org/apache/fop/fo/flow/MultiToggle.java | 50 -- src/org/apache/fop/fo/flow/PageNumber.java | 115 ---- .../fop/fo/flow/PageNumberCitation.java | 221 ------ .../apache/fop/fo/flow/RetrieveMarker.java | 162 ----- src/org/apache/fop/fo/flow/RowSpanMgr.java | 128 ---- src/org/apache/fop/fo/flow/StaticContent.java | 108 --- src/org/apache/fop/fo/flow/Table.java | 412 ------------ .../apache/fop/fo/flow/TableAndCaption.java | 66 -- src/org/apache/fop/fo/flow/TableBody.java | 261 -------- src/org/apache/fop/fo/flow/TableCaption.java | 64 -- src/org/apache/fop/fo/flow/TableCell.java | 462 ------------- src/org/apache/fop/fo/flow/TableColumn.java | 126 ---- src/org/apache/fop/fo/flow/TableFooter.java | 48 -- src/org/apache/fop/fo/flow/TableHeader.java | 40 -- src/org/apache/fop/fo/flow/TableRow.java | 545 --------------- src/org/apache/fop/fo/flow/Wrapper.java | 48 -- 49 files changed, 8232 deletions(-) delete mode 100644 src/org/apache/fop/apps/AWTStarter.java delete mode 100644 src/org/apache/fop/apps/CommandLineOptions.java delete mode 100644 src/org/apache/fop/apps/PDFOutputHandler.java delete mode 100644 src/org/apache/fop/apps/PrintStarter.java delete mode 100644 src/org/apache/fop/apps/Starter.java delete mode 100644 src/org/apache/fop/apps/StreamRenderer.java delete mode 100644 src/org/apache/fop/apps/TraxInputHandler.java delete mode 100644 src/org/apache/fop/apps/XSLTInputHandler.java delete mode 100644 src/org/apache/fop/apps/XTDriver.java delete mode 100644 src/org/apache/fop/fo/flow/BasicLink.java delete mode 100644 src/org/apache/fop/fo/flow/BidiOverride.java delete mode 100644 src/org/apache/fop/fo/flow/Block.java delete mode 100644 src/org/apache/fop/fo/flow/BlockContainer.java delete mode 100644 src/org/apache/fop/fo/flow/Character.java delete mode 100644 src/org/apache/fop/fo/flow/ExternalGraphic.java delete mode 100644 src/org/apache/fop/fo/flow/Float.java delete mode 100644 src/org/apache/fop/fo/flow/Flow.java delete mode 100644 src/org/apache/fop/fo/flow/Footnote.java delete mode 100644 src/org/apache/fop/fo/flow/FootnoteBody.java delete mode 100644 src/org/apache/fop/fo/flow/InitialPropertySet.java delete mode 100644 src/org/apache/fop/fo/flow/Inline.java delete mode 100644 src/org/apache/fop/fo/flow/InlineContainer.java delete mode 100644 src/org/apache/fop/fo/flow/InstreamForeignObject.java delete mode 100644 src/org/apache/fop/fo/flow/Leader.java delete mode 100644 src/org/apache/fop/fo/flow/ListBlock.java delete mode 100644 src/org/apache/fop/fo/flow/ListItem.java delete mode 100644 src/org/apache/fop/fo/flow/ListItemBody.java delete mode 100644 src/org/apache/fop/fo/flow/ListItemLabel.java delete mode 100644 src/org/apache/fop/fo/flow/Marker.java delete mode 100644 src/org/apache/fop/fo/flow/MultiCase.java delete mode 100644 src/org/apache/fop/fo/flow/MultiProperties.java delete mode 100644 src/org/apache/fop/fo/flow/MultiPropertySet.java delete mode 100644 src/org/apache/fop/fo/flow/MultiSwitch.java delete mode 100644 src/org/apache/fop/fo/flow/MultiToggle.java delete mode 100644 src/org/apache/fop/fo/flow/PageNumber.java delete mode 100644 src/org/apache/fop/fo/flow/PageNumberCitation.java delete mode 100644 src/org/apache/fop/fo/flow/RetrieveMarker.java delete mode 100644 src/org/apache/fop/fo/flow/RowSpanMgr.java delete mode 100644 src/org/apache/fop/fo/flow/StaticContent.java delete mode 100644 src/org/apache/fop/fo/flow/Table.java delete mode 100644 src/org/apache/fop/fo/flow/TableAndCaption.java delete mode 100644 src/org/apache/fop/fo/flow/TableBody.java delete mode 100644 src/org/apache/fop/fo/flow/TableCaption.java delete mode 100644 src/org/apache/fop/fo/flow/TableCell.java delete mode 100644 src/org/apache/fop/fo/flow/TableColumn.java delete mode 100644 src/org/apache/fop/fo/flow/TableFooter.java delete mode 100644 src/org/apache/fop/fo/flow/TableHeader.java delete mode 100644 src/org/apache/fop/fo/flow/TableRow.java delete mode 100644 src/org/apache/fop/fo/flow/Wrapper.java diff --git a/src/org/apache/fop/apps/AWTStarter.java b/src/org/apache/fop/apps/AWTStarter.java deleted file mode 100644 index c956da97f..000000000 --- a/src/org/apache/fop/apps/AWTStarter.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.apps; -/* - * originally contributed by - * Juergen Verwohlt: Juergen.Verwohlt@jCatalog.com, - * Rainer Steinkuhle: Rainer.Steinkuhle@jCatalog.com, - * Stanislav Gorkhover: Stanislav.Gorkhover@jCatalog.com - * Modified to use streaming API by Mark Lillywhite, mark-fop@inomial.com - */ -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.viewer.*; -import org.apache.fop.render.awt.*; - - -import javax.swing.UIManager; -import java.awt.*; - -// SAX -import org.xml.sax.XMLReader; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; - - - -// Java -import java.io.FileReader; -import java.io.File; -import java.io.FileWriter; -import java.io.PrintWriter; -import java.io.IOException; -import java.io.FileNotFoundException; -import java.io.FileInputStream; -import java.io.InputStream; -import java.net.URL; -import java.util.*; - - - -/** - * initialize AWT previewer - */ - -public class AWTStarter extends CommandLineStarter { - - PreviewDialog frame; - AWTRenderer renderer; - public static String TRANSLATION_PATH = - "/org/apache/fop/viewer/resources/"; - - private Translator resource; - - public AWTStarter(CommandLineOptions commandLineOptions) - throws FOPException { - super(commandLineOptions); - init(); - } - - private void init() { - try { - UIManager.setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel()); - } catch (Exception e) { - e.printStackTrace(); - } - - String language = commandLineOptions.getLanguage(); - - if (language == null) - language = System.getProperty("user.language"); - - resource = getResourceBundle(TRANSLATION_PATH + "resources." - + language); - - UserMessage.setTranslator(getResourceBundle(TRANSLATION_PATH - + "messages." - + language)); - - resource.setMissingEmphasized(false); - renderer = new AWTRenderer(resource); - frame = createPreviewDialog(renderer, resource); - renderer.setProgressListener(frame); - renderer.setComponent(frame); - MessageHandler.setOutputMethod(MessageHandler.EVENT); - MessageHandler.addListener(frame); - } - - - public void run() throws FOPException { - Driver driver = new Driver(); - if (errorDump) { - driver.setErrorDump(true); - } - - // init parser - frame.progress(resource.getString("Init parser") + " ..."); - XMLReader parser = inputHandler.getParser(); - - if (parser == null) { - throw new FOPException("Unable to create SAX parser"); - } - - setParserFeatures(parser); - - try { - driver.setRenderer(renderer); - - // build FO tree: time - frame.progress(resource.getString("Build FO tree") + " ..."); - driver.render(parser, inputHandler.getInputSource()); - - frame.progress(resource.getString("Show")); - frame.showPage(); - - } catch (Exception e) { - if (e instanceof FOPException) { - throw (FOPException)e; - } - throw new FOPException(e); - } - - } - - protected PreviewDialog createPreviewDialog(AWTRenderer renderer, - Translator res) { - PreviewDialog frame = new PreviewDialog(renderer, res); - frame.validate(); - - // center window - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - Dimension frameSize = frame.getSize(); - if (frameSize.height > screenSize.height) - frameSize.height = screenSize.height; - if (frameSize.width > screenSize.width) - frameSize.width = screenSize.width; - frame.setLocation((screenSize.width - frameSize.width) / 2, - (screenSize.height - frameSize.height) / 2); - frame.setVisible(true); - return frame; - } - - - - private SecureResourceBundle getResourceBundle(String path) { - InputStream in = null; - - try { - URL url = getClass().getResource(path); - in = url.openStream(); - } catch (Exception ex) { - MessageHandler.logln("Can't find URL to: <" + path + "> " - + ex.getMessage()); - } - return new SecureResourceBundle(in); - } - -} - - - diff --git a/src/org/apache/fop/apps/CommandLineOptions.java b/src/org/apache/fop/apps/CommandLineOptions.java deleted file mode 100644 index c13e65518..000000000 --- a/src/org/apache/fop/apps/CommandLineOptions.java +++ /dev/null @@ -1,630 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.apps; - -// java -import java.util.Vector; -import java.io.File; -import java.io.FileNotFoundException; - -// FOP -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.configuration.Configuration; -import org.apache.fop.apps.FOPException; - -/** - * Options parses the commandline arguments - */ -public class CommandLineOptions { - - /* input / output not set */ - private static final int NOT_SET = 0; - /* input: fo file */ - private static final int FO_INPUT = 1; - /* input: xml+xsl file */ - private static final int XSLT_INPUT = 2; - /* output: pdf file */ - private static final int PDF_OUTPUT = 1; - /* output: screen using swing */ - private static final int AWT_OUTPUT = 2; - /* output: mif file */ - private static final int MIF_OUTPUT = 3; - /* output: sent swing rendered file to printer */ - private static final int PRINT_OUTPUT = 4; - /* output: pcl file */ - private static final int PCL_OUTPUT = 5; - /* output: postscript file */ - private static final int PS_OUTPUT = 6; - /* output: text file */ - private static final int TXT_OUTPUT = 7; - - /* System buffers */ - private static final int BUFFER_FILE = 8; - - /* System buffers */ - private static final int AREA_OUTPUT = 9; - - /* use debug mode */ - Boolean errorDump = new Boolean(false); - /* show configuration information */ - Boolean dumpConfiguration = new Boolean(false); - /* suppress any progress information */ - Boolean quiet = new Boolean(false); - /* for area tree XML output, only down to block area level */ - Boolean suppressLowLevelAreas = new Boolean(false); - /* name of user configuration file */ - File userConfigFile = null; - /* name of input fo file */ - File fofile = null; - /* name of xsltfile (xslt transformation as input) */ - File xsltfile = null; - /* name of xml file (xslt transformation as input) */ - File xmlfile = null; - /* name of output file */ - File outfile = null; - /* name of buffer file */ - File bufferFile = null; - /* input mode */ - int inputmode = NOT_SET; - /* output mode */ - int outputmode = NOT_SET; - /* buffer mode */ - int buffermode = NOT_SET; - /* language for user information */ - String language = null; - - private java.util.Hashtable rendererOptions; - - public CommandLineOptions(String[] args) - throws FOPException, FileNotFoundException { - boolean optionsParsed = true; - rendererOptions = new java.util.Hashtable(); - try { - optionsParsed = parseOptions(args); - if (optionsParsed) { - checkSettings(); - if (errorDump != null && errorDump.booleanValue()) { - debug(); - } - } - } catch (FOPException e) { - printUsage(); - throw e; - } catch (java.io.FileNotFoundException e) { - printUsage(); - throw e; - } - - } - - /** - * parses the commandline arguments - * @return true if parse was successful and procesing can continue, false if processing should stop - * @exception FOPException if there was an error in the format of the options - */ - private boolean parseOptions(String args[]) throws FOPException { - for (int i = 0; i < args.length; i++) { - if (args[i].equals("-d") || args[i].equals("--full-error-dump")) { - errorDump = new Boolean(true); - } else if (args[i].equals("-x") - || args[i].equals("--dump-config")) { - dumpConfiguration = new Boolean(true); - } else if (args[i].equals("-q") || args[i].equals("--quiet")) { - quiet = new Boolean(true); - } else if (args[i].equals("-c")) { - if ((i + 1 == args.length) - || (args[i + 1].charAt(0) == '-')) { - throw new FOPException("if you use '-c', you must specify the name of the configuration file"); - } else { - userConfigFile = new File(args[i + 1]); - i++; - } - } else if (args[i].equals("-l")) { - if ((i + 1 == args.length) - || (args[i + 1].charAt(0) == '-')) { - throw new FOPException("if you use '-l', you must specify a language"); - } else { - language = args[i + 1]; - i++; - } - } else if (args[i].equals("-s")) { - suppressLowLevelAreas = new Boolean(true); - } else if (args[i].equals("-fo")) { - inputmode = FO_INPUT; - if ((i + 1 == args.length) - || (args[i + 1].charAt(0) == '-')) { - throw new FOPException("you must specify the fo file for the '-fo' option"); - } else { - fofile = new File(args[i + 1]); - i++; - } - } else if (args[i].equals("-xsl")) { - inputmode = XSLT_INPUT; - if ((i + 1 == args.length) - || (args[i + 1].charAt(0) == '-')) { - throw new FOPException("you must specify the stylesheet file for the '-xsl' option"); - } else { - xsltfile = new File(args[i + 1]); - i++; - } - } else if (args[i].equals("-xml")) { - inputmode = XSLT_INPUT; - if ((i + 1 == args.length) - || (args[i + 1].charAt(0) == '-')) { - throw new FOPException("you must specify the input file for the '-xml' option"); - } else { - xmlfile = new File(args[i + 1]); - i++; - } - } else if (args[i].equals("-awt")) { - setOutputMode(AWT_OUTPUT); - } else if (args[i].equals("-pdf")) { - setOutputMode(PDF_OUTPUT); - if ((i + 1 == args.length) - || (args[i + 1].charAt(0) == '-')) { - throw new FOPException("you must specify the pdf output file"); - } else { - outfile = new File(args[i + 1]); - i++; - } - } else if (args[i].equals("-mif")) { - setOutputMode(MIF_OUTPUT); - if ((i + 1 == args.length) - || (args[i + 1].charAt(0) == '-')) { - throw new FOPException("you must specify the mif output file"); - } else { - outfile = new File(args[i + 1]); - i++; - } - } else if (args[i].equals("-print")) { - setOutputMode(PRINT_OUTPUT); - // show print help - if (i + 1 < args.length) { - if (args[i + 1].equals("help")) { - printUsagePrintOutput(); - return false; - } - } - } else if (args[i].equals("-pcl")) { - setOutputMode(PCL_OUTPUT); - if ((i + 1 == args.length) - || (args[i + 1].charAt(0) == '-')) { - throw new FOPException("you must specify the pdf output file"); - } else { - outfile = new File(args[i + 1]); - i++; - } - } else if (args[i].equals("-ps")) { - setOutputMode(PS_OUTPUT); - if ((i + 1 == args.length) - || (args[i + 1].charAt(0) == '-')) { - throw new FOPException("you must specify the PostScript output file"); - } else { - outfile = new File(args[i + 1]); - i++; - } - } else if (args[i].equals("-txt")) { - setOutputMode(TXT_OUTPUT); - if ((i + 1 == args.length) - || (args[i + 1].charAt(0) == '-')) { - throw new FOPException("you must specify the text output file"); - } else { - outfile = new File(args[i + 1]); - i++; - } - } else if (args[i].charAt(0) != '-') { - if (inputmode == NOT_SET) { - inputmode = FO_INPUT; - fofile = new File(args[i]); - } else if (outputmode == NOT_SET) { - outputmode = PDF_OUTPUT; - outfile = new File(args[i]); - } else { - throw new FOPException("Don't know what to do with " - + args[i]); - } - } else if (args[i].equals("-buf")) { - if (buffermode == NOT_SET) { - buffermode = BUFFER_FILE; - } else { - MessageHandler.errorln("ERROR: you can only set one buffer method"); - printUsage(); - } - if ((i + 1 == args.length) - || (args[i + 1].charAt(0) == '-')) { - MessageHandler.errorln("ERROR: you must specify the buffer output file"); - printUsage(); - } else { - bufferFile = new File(args[i + 1]); - i++; - } - } else if (args[i].equals("-at")) { - setOutputMode(AREA_OUTPUT); - if ((i + 1 == args.length) - || (args[i + 1].charAt(0) == '-')) { - throw new FOPException("you must specify the area-tree output file"); - } else { - outfile = new File(args[i + 1]); - i++; - } - } else { - printUsage(); - return false; - } - } - return true; - } // end parseOptions - - private void setOutputMode(int mode) throws FOPException { - if (outputmode == NOT_SET) { - outputmode = mode; - } else { - throw new FOPException("you can only set one output method"); - } - } - - /** - * checks whether all necessary information has been given in a consistent way - */ - private void checkSettings() throws FOPException, FileNotFoundException { - if (inputmode == NOT_SET) { - throw new FOPException("No input file specified"); - } - - if (outputmode == NOT_SET) { - throw new FOPException("No output file specified"); - } - - if (inputmode == XSLT_INPUT) { - // check whether xml *and* xslt file have been set - if (xmlfile == null) { - throw new FOPException("XML file must be specified for the tranform mode"); - } - if (xsltfile == null) { - throw new FOPException("XSLT file must be specified for the tranform mode"); - } - - // warning if fofile has been set in xslt mode - if (fofile != null) { - MessageHandler.errorln("WARNING: Can't use fo file with transform mode! Ignoring.\n" - + "Your input is " + "\n xmlfile: " - + xmlfile.getAbsolutePath() - + "\nxsltfile: " - + xsltfile.getAbsolutePath() - + "\n fofile: " - + fofile.getAbsolutePath()); - } - if (!xmlfile.exists()) { - throw new FileNotFoundException("xml file " - + xmlfile.getAbsolutePath() - + " not found "); - } - if (!xsltfile.exists()) { - throw new FileNotFoundException("xsl file " - + xsltfile.getAbsolutePath() - + " not found "); - } - - } else if (inputmode == FO_INPUT) { - if (xmlfile != null || xsltfile != null) { - MessageHandler.errorln("WARNING: fo input mode, but xmlfile or xslt file are set:"); - MessageHandler.errorln("xml file: " + xmlfile.toString()); - MessageHandler.errorln("xslt file: " + xsltfile.toString()); - } - if (!fofile.exists()) { - throw new FileNotFoundException("fo file " - + fofile.getAbsolutePath() - + " not found "); - } - - } - } // end checkSettings - - /** - * returns the chosen renderer, throws FOPException - */ - public int getRenderer() throws FOPException { - switch (outputmode) { - case NOT_SET: - throw new FOPException("Renderer has not been set!"); - case PDF_OUTPUT: - return Driver.RENDER_PDF; - case AWT_OUTPUT: - return Driver.RENDER_AWT; - case MIF_OUTPUT: - return Driver.RENDER_MIF; - case PRINT_OUTPUT: - return Driver.RENDER_PRINT; - case PCL_OUTPUT: - return Driver.RENDER_PCL; - case PS_OUTPUT: - return Driver.RENDER_PS; - case TXT_OUTPUT: - return Driver.RENDER_TXT; - case AREA_OUTPUT: - rendererOptions.put("fineDetail", isCoarseAreaXml()); - return Driver.RENDER_XML; - default: - throw new FOPException("Invalid Renderer setting!"); - } - } - - /** - * - */ - public InputHandler getInputHandler() { - switch (inputmode) { - case FO_INPUT: - return new FOInputHandler(fofile); - case XSLT_INPUT: - return new XSLTInputHandler(xmlfile, xsltfile); - default: - return new FOInputHandler(fofile); - } - } - - public java.util.Hashtable getRendererOptions() { - return rendererOptions; - } - - public Starter getStarter() throws FOPException { - switch (outputmode) { - case AWT_OUTPUT: - try { - return ((Starter)Class.forName("org.apache.fop.apps.AWTStarter").getConstructor(new Class[] { - CommandLineOptions.class - }).newInstance(new Object[] { - this - })); - } catch (Exception e) { - if (e instanceof FOPException) { - throw (FOPException)e; - } - throw new FOPException("AWTStarter could not be loaded.", e); - } - case PRINT_OUTPUT: - try { - return ((Starter)Class.forName("org.apache.fop.apps.PrintStarter").getConstructor(new Class[] { - CommandLineOptions.class - }).newInstance(new Object[] { - this - })); - } catch (Exception e) { - if (e instanceof FOPException) { - throw (FOPException)e; - } - throw new FOPException("PrintStarter could not be loaded.", - e); - } - - default: - return new CommandLineStarter(this); - } - } - - public int getInputMode() { - return inputmode; - } - - public int getOutputMode() { - return outputmode; - } - - public File getFOFile() { - return fofile; - } - - public File getXMLFile() { - return xmlfile; - } - - public File getXSLFile() { - return xsltfile; - } - - public File getOutputFile() { - return outfile; - } - - public File getUserConfigFile() { - return userConfigFile; - } - - public String getLanguage() { - return language; - } - - public File getBufferFile() { - return bufferFile; - } - - public Boolean isQuiet() { - return quiet; - } - - public Boolean dumpConfiguration() { - return dumpConfiguration; - } - - public Boolean isDebugMode() { - return errorDump; - } - - public Boolean isCoarseAreaXml() { - return suppressLowLevelAreas; - } - - /** - * return either the fofile or the xmlfile - */ - public File getInputFile() { - switch (inputmode) { - case FO_INPUT: - return fofile; - case XSLT_INPUT: - return xmlfile; - default: - return fofile; - } - } - - /** - * shows the commandline syntax including a summary of all available options and some examples - */ - public static void printUsage() { - MessageHandler.errorln("\nUSAGE\nFop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-pcl|-ps|-txt|-at|-print] \n" - + " [OPTIONS] \n" - + " -d debug mode \n" - + " -x dump configuration settings \n" - + " -q quiet mode \n" - + " -c cfg.xml use additional configuration file cfg.xml\n" - + " -l lang the language to use for user information \n" - + " -s for area tree XML, down to block areas only\n\n" - + " [INPUT] \n" - + " infile xsl:fo input file (the same as the next) \n" - + " -fo infile xsl:fo input file \n" - + " -xml infile xml input file, must be used together with -xsl \n" - + " -xsl stylesheet xslt stylesheet \n \n" - + " [OUTPUT] \n" - + " outfile input will be rendered as pdf file into outfile \n" - + " -pdf outfile input will be rendered as pdf file (outfile req'd) \n" - + " -awt input will be displayed on screen \n" - + " -mif outfile input will be rendered as mif file (outfile req'd)\n" - + " -pcl outfile input will be rendered as pcl file (outfile req'd) \n" - + " -ps outfile input will be rendered as PostScript file (outfile req'd) \n" - + " -txt outfile input will be rendered as text file (outfile req'd) \n" - + " -at outfile representation of area tree as XML (outfile req'd) \n" - + " -print input file will be rendered and sent to the printer \n" - + " see options with \"-print help\" \n\n" - + " [Examples]\n" + " Fop foo.fo foo.pdf \n" - + " Fop -fo foo.fo -pdf foo.pdf (does the same as the previous line)\n" - + " Fop -xsl foo.xsl -xml foo.xml -pdf foo.pdf\n" - + " Fop foo.fo -mif foo.mif\n" - + " Fop foo.fo -print or Fop -print foo.fo \n" - + " Fop foo.fo -awt \n"); - } - - /** - * shows the options for print output - */ - public void printUsagePrintOutput() { - MessageHandler.errorln("USAGE: -print [-Dstart=i] [-Dend=i] [-Dcopies=i] [-Deven=true|false] " - + " org.apache.fop.apps.Fop (..) -print \n" - + "Example:\n" - + "java -Dstart=1 -Dend=2 org.apache.Fop.apps.Fop infile.fo -print "); - } - - - /** - * debug mode. outputs all commandline settings - */ - private void debug() { - System.out.print("Input mode: "); - switch (inputmode) { - case NOT_SET: - MessageHandler.logln("not set"); - break; - case FO_INPUT: - MessageHandler.logln("FO "); - MessageHandler.logln("fo input file: " + fofile.toString()); - break; - case XSLT_INPUT: - MessageHandler.logln("xslt transformation"); - MessageHandler.logln("xml input file: " + xmlfile.toString()); - MessageHandler.logln("xslt stylesheet: " + xsltfile.toString()); - break; - default: - MessageHandler.logln("unknown input type"); - } - System.out.print("Output mode: "); - switch (outputmode) { - case NOT_SET: - MessageHandler.logln("not set"); - break; - case PDF_OUTPUT: - MessageHandler.logln("pdf"); - MessageHandler.logln("output file: " + outfile.toString()); - break; - case AWT_OUTPUT: - MessageHandler.logln("awt on screen"); - if (outfile != null) { - MessageHandler.logln("ERROR: awt mode, but outfile is set:"); - MessageHandler.logln("out file: " + outfile.toString()); - } - break; - case MIF_OUTPUT: - MessageHandler.logln("mif"); - MessageHandler.logln("output file: " + outfile.toString()); - break; - case PRINT_OUTPUT: - MessageHandler.logln("print directly"); - if (outfile != null) { - MessageHandler.logln("ERROR: print mode, but outfile is set:"); - MessageHandler.logln("out file: " + outfile.toString()); - } - break; - case PCL_OUTPUT: - MessageHandler.logln("pcl"); - MessageHandler.logln("output file: " + outfile.toString()); - break; - case PS_OUTPUT: - MessageHandler.logln("PostScript"); - MessageHandler.logln("output file: " + outfile.toString()); - break; - case TXT_OUTPUT: - MessageHandler.logln("txt"); - MessageHandler.logln("output file: " + outfile.toString()); - break; - default: - MessageHandler.logln("unknown input type"); - } - - - MessageHandler.logln("OPTIONS"); - if (userConfigFile != null) { - MessageHandler.logln("user configuration file: " - + userConfigFile.toString()); - } else { - MessageHandler.logln("no user configuration file is used [default]"); - } - if (errorDump != null) { - MessageHandler.logln("debug mode on"); - } else { - MessageHandler.logln("debug mode off [default]"); - } - if (dumpConfiguration != null) { - MessageHandler.logln("dump configuration"); - } else { - MessageHandler.logln("don't dump configuration [default]"); - } - if (quiet != null) { - MessageHandler.logln("quiet mode on"); - } else { - MessageHandler.logln("quiet mode off [default]"); - } - - } - - // debug: create class and output all settings - public static void main(String args[]) { - /* - * for (int i = 0; i < args.length; i++) { - * MessageHandler.logln(">"+args[i]+"<"); - * } - */ - try { - CommandLineOptions options = new CommandLineOptions(args); - } catch (Exception e) { - e.printStackTrace(); - } - - // options.debug(); - } - -} - diff --git a/src/org/apache/fop/apps/PDFOutputHandler.java b/src/org/apache/fop/apps/PDFOutputHandler.java deleted file mode 100644 index 0b39c67c8..000000000 --- a/src/org/apache/fop/apps/PDFOutputHandler.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.apps; - -import org.xml.sax.*; -import com.jclark.xsl.sax.*; -import java.io.*; - -// FOP -import org.apache.fop.fo.XTFOTreeBuilder; -import org.apache.fop.fo.XTElementMapping; -import org.apache.fop.layout.AreaTree; -import org.apache.fop.layout.FontInfo; -import org.apache.fop.render.Renderer; -import org.apache.fop.messaging.MessageHandler; - -// //////////////////////////////////////////////////////////////////////////////////// - -/** - * A DocumentHandler that writes a PDF representation to an OutputStream. - * - * Use with James Clark's XT. Just put FOP on your class path and add - * - * to your stylesheet. Now XT will automatically call FOP. - * - */ -public class PDFOutputHandler extends XTFOTreeBuilder - implements OutputDocumentHandler { - - /** - * the area tree that is the result of formatting the FO tree - */ - protected AreaTree areaTree; - - /** - * the renderer to use to output the area tree - */ - protected Renderer renderer; - - /** - * the PrintWriter to use to output the results of the renderer - */ - protected PrintWriter writer; - - /** - * the stream to use to output the results of the renderer - */ - protected OutputStream stream; - - private boolean keepOpen; - - // //////////////////////////////////////////////////////////////////////////////////// - - /** - */ - public PDFOutputHandler() {} - - // //////////////////////////////////////////////////////////////////////////////////// - - /** - */ - public PDFOutputHandler(OutputStream out) { - this(); - this.stream = out; - } - - // //////////////////////////////////////////////////////////////////////////////////// - - /** - */ - public DocumentHandler init(Destination dest, - AttributeList atts) throws IOException { - this.stream = dest.getOutputStream("application/pdf", null); - this.keepOpen = dest.keepOpen(); - - String version = org.apache.fop.apps.Version.getVersion(); - setRenderer("org.apache.fop.render.pdf.PDFRenderer", version); - addElementMapping("org.apache.fop.fo.StandardElementMapping"); - addElementMapping("org.apache.fop.svg.SVGElementMapping"); - return this; - } - - // //////////////////////////////////////////////////////////////////////////////////// - - /** - * set the class name of the Renderer to use as well as the - * producer string for those renderers that can make use of it - */ - public void setRenderer(String rendererClassName, String producer) { - this.renderer = createRenderer(rendererClassName); - this.renderer.setProducer(producer); - } - - // //////////////////////////////////////////////////////////////////////////////////// - - /** - * SAX passthrough, finish rendering the document - */ - public void endDocument() throws SAXException { - super.endDocument(); - - try { - doFormat(); - doRender(); - } catch (IOException io) { - throw new SAXException(io); - } catch (FOPException fop) { - throw new SAXException(fop); - } - writer.flush(); - } - - // //////////////////////////////////////////////////////////////////////////////////// - - /** - * format the formatting object tree into an area tree - */ - public void doFormat() throws FOPException { - FontInfo fontInfo = new FontInfo(); - this.renderer.setupFontInfo(fontInfo); - - this.areaTree = new AreaTree(); - this.areaTree.setFontInfo(fontInfo); - - format(areaTree); - } - - // //////////////////////////////////////////////////////////////////////////////////// - - /** - * render the area tree to the output form - */ - public void doRender() throws IOException, FOPException { - this.renderer.render(areaTree, this.stream); - } - - // //////////////////////////////////////////////////////////////////////////////////// - - /** - * add the given element mapping. - * - * an element mapping maps element names to Java classes - */ - public void addElementMapping(XTElementMapping mapping) { - mapping.addToBuilder(this); - } - - // //////////////////////////////////////////////////////////////////////////////////// - - /** - * add the element mapping with the given class name - */ - public void addElementMapping(String mappingClassName) { - createElementMapping(mappingClassName).addToBuilder(this); - } - - // //////////////////////////////////////////////////////////////////////////////////// - - /** - * protected method used by addElementMapping(String) to - * instantiate element mapping class - */ - protected XTElementMapping createElementMapping(String mappingClassName) { - MessageHandler.logln("using element mapping " + mappingClassName); - - try { - return (XTElementMapping)Class.forName(mappingClassName).newInstance(); - } catch (ClassNotFoundException e) { - MessageHandler.errorln("Could not find " + mappingClassName); - } catch (InstantiationException e) { - MessageHandler.errorln("Could not instantiate " - + mappingClassName); - } catch (IllegalAccessException e) { - MessageHandler.errorln("Could not access " + mappingClassName); - } catch (ClassCastException e) { - MessageHandler.errorln(mappingClassName - + " is not an element mapping"); - } - return null; - } - - // //////////////////////////////////////////////////////////////////////////////////// - - /** - * protected method used by setRenderer(String, String) to - * instantiate the Renderer class - */ - protected Renderer createRenderer(String rendererClassName) { - MessageHandler.logln("using renderer " + rendererClassName); - - try { - return (Renderer)Class.forName(rendererClassName).newInstance(); - } catch (ClassNotFoundException e) { - MessageHandler.errorln("Could not find " + rendererClassName); - } catch (InstantiationException e) { - MessageHandler.errorln("Could not instantiate " - + rendererClassName); - } catch (IllegalAccessException e) { - MessageHandler.errorln("Could not access " + rendererClassName); - } catch (ClassCastException e) { - MessageHandler.errorln(rendererClassName + " is not a renderer"); - } - return null; - } - -} - diff --git a/src/org/apache/fop/apps/PrintStarter.java b/src/org/apache/fop/apps/PrintStarter.java deleted file mode 100644 index f3c039f64..000000000 --- a/src/org/apache/fop/apps/PrintStarter.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.apps; - -/* - * originally contributed by - * Stanislav Gorkhover: stanislav.gorkhover@jcatalog.com - * jCatalog Software AG - * - * Updated by Mark Lillywhite, mark-fop@inomial.com. Modified to - * handle the print job better, added -Ddialog option, removed - * (apparently) redundant copies code, generally cleaned up, and - * added interfaces to the new Render API. - */ - - -import org.xml.sax.XMLReader; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; - -import java.awt.Graphics; -import java.awt.print.*; -import java.io.OutputStream; -import java.io.IOException; -import java.util.Vector; - -import org.apache.fop.render.awt.AWTRenderer; -import org.apache.fop.layout.AreaTree; -import org.apache.fop.layout.Page; -import org.apache.fop.messaging.MessageHandler; - - -/** - * This class prints a xsl-fo dokument without interaction. - * At the moment java has not the possibility to configure the printer and it's - * options without interaction (30.03.2000). - * This class allows to print a set of pages (from-to), even/odd pages and many copies. - * - Print from page xxx: property name - start, value int - * - Print to page xxx: property name - end, value int - * - Print even/odd pages: property name - even, value boolean - * - Print xxx copies: property name - copies, value int - * - */ -public class PrintStarter extends CommandLineStarter { - - public PrintStarter(CommandLineOptions options) throws FOPException { - super(options); - } - - public void run() throws FOPException { - Driver driver = new Driver(); - if (errorDump) { - driver.setErrorDump(true); - } - - String version = Version.getVersion(); - MessageHandler.errorln(version); - - XMLReader parser = inputHandler.getParser(); - - setParserFeatures(parser); - - PrinterJob pj = PrinterJob.getPrinterJob(); - if(System.getProperty("dialog") != null) - if(!pj.printDialog()) - throw new FOPException("Printing cancelled by operator"); - - PrintRenderer renderer = new PrintRenderer(pj); - int copies = getIntProperty("copies", 1); - pj.setCopies(copies); - - //renderer.setCopies(copies); - - try { - driver.setRenderer(renderer); - driver.render(parser, inputHandler.getInputSource()); - } catch (Exception e) { - if (e instanceof FOPException) { - throw (FOPException)e; - } - throw new FOPException(e); - } - - System.exit(0); - } - int getIntProperty(String name, int def) { - String propValue = System.getProperty(name); - if(propValue != null) { - try { - return Integer.parseInt(propValue); - } catch (Exception e) { - return def; - } - } else { - return def; - } - } - - class PrintRenderer extends AWTRenderer { - - private static final int EVEN_AND_ALL = 0; - private static final int EVEN = 1; - private static final int ODD = 2; - - private int startNumber; - private int endNumber; - private int mode = EVEN_AND_ALL; - private int copies = 1; - private PrinterJob printerJob; - - PrintRenderer(PrinterJob printerJob) { - super(null); - - this.printerJob = printerJob; - startNumber = getIntProperty("start", 1) - 1; - endNumber = getIntProperty("end", -1); - - printerJob.setPageable(this); - - mode = EVEN_AND_ALL; - String str = System.getProperty("even"); - if (str != null) { - try { - mode = Boolean.valueOf(str).booleanValue() ? EVEN : ODD; - } catch (Exception e) {} - - } - - } - - - - public void stopRenderer(OutputStream outputStream) - throws IOException { - super.stopRenderer(outputStream); - - if(endNumber == -1) - endNumber = getPageCount(); - - Vector numbers = getInvalidPageNumbers(); - for (int i = numbers.size() - 1; i > -1; i--) - removePage(Integer.parseInt((String)numbers.elementAt(i))); - - try { - printerJob.print(); - } catch (PrinterException e) { - e.printStackTrace(); - throw new IOException( - "Unable to print: " + e.getClass().getName() + - ": " + e.getMessage()); - } - } - - public void renderPage(Page page) { - pageWidth = (int)((float)page.getWidth() / 1000f); - pageHeight = (int)((float)page.getHeight() / 1000f); - super.renderPage(page); - } - - - private Vector getInvalidPageNumbers() { - - Vector vec = new Vector(); - int max = getPageCount(); - boolean isValid; - for (int i = 0; i < max; i++) { - isValid = true; - if (i < startNumber || i > endNumber) { - isValid = false; - } else if (mode != EVEN_AND_ALL) { - if (mode == EVEN && ((i + 1) % 2 != 0)) - isValid = false; - else if (mode == ODD && ((i + 1) % 2 != 1)) - isValid = false; - } - - if (!isValid) - vec.add(i + ""); - } - - return vec; - } - - /* TODO: I'm totally not sure that this is necessary -Mark - void setCopies(int val) { - copies = val; - Vector copie = tree.getPages(); - for (int i = 1; i < copies; i++) { - tree.getPages().addAll(copie); - } - - } - */ - } // class PrintRenderer -} // class PrintCommandLine - - - diff --git a/src/org/apache/fop/apps/Starter.java b/src/org/apache/fop/apps/Starter.java deleted file mode 100644 index c0882e93f..000000000 --- a/src/org/apache/fop/apps/Starter.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.apps; - -// SAX -import org.xml.sax.XMLReader; -import org.xml.sax.SAXException; - -// Java -import java.io.*; -import java.net.URL; - -// FOP -import org.apache.fop.messaging.MessageHandler; - -/** - * abstract super class - * Creates a SAX Parser (defaulting to Xerces). - * - */ -public abstract class Starter { - - Options options; - InputHandler inputHandler; - - public Starter() throws FOPException { - options = new Options(); - } - - public void setInputHandler(InputHandler inputHandler) { - this.inputHandler = inputHandler; - } - - abstract public void run() throws FOPException; - - // setting the parser features - public void setParserFeatures(XMLReader parser) throws FOPException { - try { - parser.setFeature("http://xml.org/sax/features/namespace-prefixes", - true); - } catch (SAXException e) { - throw new FOPException("Error in setting up parser feature namespace-prefixes\n" - + "You need a parser which supports SAX version 2", e); - } - } - -} diff --git a/src/org/apache/fop/apps/StreamRenderer.java b/src/org/apache/fop/apps/StreamRenderer.java deleted file mode 100644 index 448ec0d66..000000000 --- a/src/org/apache/fop/apps/StreamRenderer.java +++ /dev/null @@ -1,315 +0,0 @@ -package org.apache.fop.apps; - -import java.io.OutputStream; -import java.io.IOException; -import java.util.Vector; -import java.util.Enumeration; - -import org.xml.sax.SAXException; - -import org.apache.fop.layout.FontInfo; -import org.apache.fop.layout.Page; -import org.apache.fop.render.Renderer; -import org.apache.fop.layout.AreaTree; -import org.apache.fop.datatypes.IDReferences; -import org.apache.fop.extensions.ExtensionObj; -import org.apache.fop.fo.pagination.PageSequence; -import org.apache.fop.messaging.MessageHandler; - -/** - This class acts as a bridge between the XML:FO parser - and the formatting/rendering classes. It will queue - PageSequences up until all the IDs required by them - are satisfied, at which time it will render the - pages.

- - StreamRenderer is created by Driver and called from - FOTreeBuilder when a PageSequence is created, - and AreaTree when a Page is formatted.

-*/ -public class StreamRenderer extends Object { - private static final boolean MEM_PROFILE_WITH_GC = false; - - /** - Somewhere to get our stats from. - */ - private Runtime runtime = Runtime.getRuntime(); - - /** - Keep track of the number of pages rendered. - */ - int pageCount = 0; - - /** - Keep track of heap memory allocated, - for statistical purposes. - */ - private long initialMemory; - - /** - Keep track of time used by renderer. - */ - private long startTime; - - /** - The stream to which this rendering is to be - written to. Note that some renderers - do not render to a stream, and that this - member can therefore be null. - */ - private OutputStream outputStream; - - /** - The renderer being used. - */ - private Renderer renderer; - - /** - The FontInfo for this renderer. - */ - private FontInfo fontInfo = new FontInfo(); - - /** - The list of pages waiting to be renderered. - */ - private Vector renderQueue = new Vector(); - - /** - The current set of IDReferences, passed to the - areatrees and pages. This is used by the AreaTree - as a single map of all IDs. - */ - private IDReferences idReferences = new IDReferences(); - - public StreamRenderer(OutputStream outputStream, Renderer renderer) { - this.outputStream = outputStream; - this.renderer = renderer; - } - - public IDReferences getIDReferences() { - return idReferences; - } - - public void startRenderer() - throws SAXException { - pageCount = 0; - - if (MEM_PROFILE_WITH_GC) - System.gc(); // This takes time but gives better results - - initialMemory = runtime.totalMemory() - runtime.freeMemory(); - startTime = System.currentTimeMillis(); - - try { - renderer.setupFontInfo(fontInfo); - renderer.startRenderer(outputStream); - } catch (IOException e) { - throw new SAXException(e); - } - } - - public void stopRenderer() - throws SAXException { - /* - Force the processing of any more queue elements, - even if they are not resolved. - */ - try { - processQueue(true); - renderer.stopRenderer(outputStream); - } catch (FOPException e) { - throw new SAXException(e); - } - catch (IOException e) { - throw new SAXException(e); - } - - if (MEM_PROFILE_WITH_GC) - System.gc(); // This takes time but gives better results - - long memoryNow = runtime.totalMemory() - runtime.freeMemory(); - long memoryUsed = (memoryNow - initialMemory) / 1024L; - - MessageHandler.logln("Initial heap size: " + (initialMemory/1024L) + "Kb"); - MessageHandler.logln("Current heap size: " + (memoryNow/1024L) + "Kb"); - MessageHandler.logln("Total memory used: " + memoryUsed + "Kb"); - - if (!MEM_PROFILE_WITH_GC) { - MessageHandler.logln(" Memory use is indicative; no GC was performed"); - MessageHandler.logln(" These figures should not be used comparatively"); - } - - long timeUsed = System.currentTimeMillis() - startTime; - - MessageHandler.logln("Total time used: " + timeUsed + "ms"); - MessageHandler.logln("Pages rendererd: " + pageCount); - MessageHandler.logln("Avg render time: " + (timeUsed / pageCount) + "ms/page"); - } - - /** - Format the PageSequence. The PageSequence - formats Pages and adds them to the AreaTree, - which subsequently calls the StreamRenderer - instance (this) again to render the page. - At this time the page might be printed - or it might be queued. A page might not - be renderable immediately if the IDReferences - are not all valid. In this case we defer - the rendering until they are all valid. - */ - public void render(PageSequence pageSequence) - throws SAXException { - AreaTree a = new AreaTree(this); - a.setFontInfo(fontInfo); - - try { - pageSequence.format(a); - } catch (FOPException e) { - throw new SAXException(e); - } - } - - public synchronized void queuePage(Page page) - throws FOPException, IOException { - /* - Try to optimise on the common case that there are - no pages pending and that all ID references are - valid on the current pages. This short-cuts the - pipeline and renders the area immediately. - */ - if ((renderQueue.size() == 0) && idReferences.isEveryIdValid()) - renderer.render(page, outputStream); - else - addToRenderQueue(page); - - pageCount++; - } - - private synchronized void addToRenderQueue(Page page) - throws FOPException, IOException { - RenderQueueEntry entry = new RenderQueueEntry(page); - renderQueue.addElement(entry); - - /* - The just-added entry could (possibly) resolve the - waiting entries, so we try to process the queue - now to see. - */ - processQueue(false); - } - - /** - Try to process the queue from the first entry forward. - If an entry can't be processed, then the queue can't - move forward, so return. - */ - private synchronized void processQueue(boolean force) - throws FOPException, IOException { - while (renderQueue.size() > 0) { - RenderQueueEntry entry = (RenderQueueEntry) renderQueue.elementAt(0); - if ((!force) && (!entry.isResolved())) - break; - - renderer.render(entry.getPage(), outputStream); - - /* TODO - Enumeration rootEnumeration = - entry.getAreaTree().getExtensions().elements(); - while (rootEnumeration.hasMoreElements()) - renderTree.addExtension((ExtensionObj) rootEnumeration.nextElement()); - */ - - renderQueue.removeElementAt(0); - } - } - - /** - A RenderQueueEntry consists of the Page to be queued, - plus a list of outstanding ID references that need to be - resolved before the Page can be renderered.

- */ - class RenderQueueEntry extends Object { - /* - The Page that has outstanding ID references. - */ - private Page page; - - /* - A list of ID references (names). - */ - private Vector unresolvedIdReferences = new Vector(); - - public RenderQueueEntry(Page page) { - this.page = page; - - Enumeration e = idReferences.getInvalidElements(); - while (e.hasMoreElements()) - unresolvedIdReferences.addElement(e.nextElement()); - } - - public Page getPage() { - return page; - } - - /** - See if the outstanding references are resolved - in the current copy of IDReferences. - */ - public boolean isResolved() { - if ((unresolvedIdReferences.size() == 0) || idReferences.isEveryIdValid()) - return true; - - // - // See if any of the unresolved references are still unresolved. - // - Enumeration e = unresolvedIdReferences.elements(); - while (e.hasMoreElements()) - if (!idReferences.doesIDExist((String) e.nextElement())) - return false; - - unresolvedIdReferences.removeAllElements(); - return true; - } - } - - public Page getNextPage(Page current, boolean isWithinPageSequence, - boolean isFirstCall) { - Page nextPage = null; - int pageIndex = 0; - if (isFirstCall) - pageIndex = renderQueue.size(); - else - pageIndex = renderQueue.indexOf(current); - if ((pageIndex + 1) < renderQueue.size()) { - nextPage = (Page)renderQueue.elementAt(pageIndex + 1); - if (isWithinPageSequence - &&!nextPage.getPageSequence().equals(current.getPageSequence())) { - nextPage = null; - } - } - return nextPage; - } - - public Page getPreviousPage(Page current, boolean isWithinPageSequence, - boolean isFirstCall) { - Page previousPage = null; - int pageIndex = 0; - if (isFirstCall) - pageIndex = renderQueue.size(); - else - pageIndex = renderQueue.indexOf(current); - // System.out.println("Page index = " + pageIndex); - if ((pageIndex - 1) >= 0) { - previousPage = (Page)renderQueue.elementAt(pageIndex - 1); - PageSequence currentPS = current.getPageSequence(); - // System.out.println("Current PS = '" + currentPS + "'"); - PageSequence previousPS = previousPage.getPageSequence(); - // System.out.println("Previous PS = '" + previousPS + "'"); - if (isWithinPageSequence &&!previousPS.equals(currentPS)) { - // System.out.println("Outside page sequence"); - previousPage = null; - } - } - return previousPage; - } -} diff --git a/src/org/apache/fop/apps/TraxInputHandler.java b/src/org/apache/fop/apps/TraxInputHandler.java deleted file mode 100644 index 4cebd7521..000000000 --- a/src/org/apache/fop/apps/TraxInputHandler.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.apps; - - -// Imported TraX classes -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.stream.StreamSource; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.sax.SAXSource; -import javax.xml.transform.sax.SAXTransformerFactory; - - -// Imported SAX classes -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.XMLFilter; - - - -// Imported java.io classes -import java.io.InputStream; -import java.io.IOException; -import java.io.File; - -// FOP -import org.apache.fop.messaging.MessageHandler; - -/** - * XSLTInputHandler basically takes an xmlfile and transforms it with an xsltfile - * and the resulting xsl:fo document is input for Fop. - */ -public class TraxInputHandler extends InputHandler { - - File xmlfile, xsltfile; - - public TraxInputHandler(File xmlfile, File xsltfile) { - this.xmlfile = xmlfile; - this.xsltfile = xsltfile; - } - - /** - * overwrites the method of the super class to return the xmlfile - */ - public InputSource getInputSource() { - return fileInputSource(xmlfile); - } - - /** - * overwrites this method of the super class and returns an XMLFilter instead of a - * simple XMLReader which allows chaining of transformations - * - */ - public XMLReader getParser() throws FOPException { - return this.getXMLFilter(xmlfile, xsltfile); - } - - /** - * Creates from the transformer an instance of an XMLFilter which - * then can be used in a chain with the XMLReader passed to Driver. This way - * during the conversion of the xml file + xslt stylesheet the resulting - * data is fed into Fop. This should help to avoid memory problems - * @param xmlfile The xmlfile containing the text data - * @param xsltfile An xslt stylesheet - * @return XMLFilter an XMLFilter which can be chained together with other XMLReaders or XMLFilters - */ - public static XMLFilter getXMLFilter(File xmlfile, - File xsltfile) throws FOPException { - try { - // Instantiate a TransformerFactory. - TransformerFactory tFactory = TransformerFactory.newInstance(); - // Determine whether the TransformerFactory supports The use uf SAXSource - // and SAXResult - if (tFactory.getFeature(SAXSource.FEATURE) - && tFactory.getFeature(SAXResult.FEATURE)) { - // Cast the TransformerFactory to SAXTransformerFactory. - SAXTransformerFactory saxTFactory = - ((SAXTransformerFactory)tFactory); - // Create an XMLFilter for each stylesheet. - XMLFilter xmlfilter = - saxTFactory.newXMLFilter(new StreamSource(xsltfile)); - - // Create an XMLReader. - XMLReader parser = createParser(); - if (parser == null) { - throw new FOPException("Unable to create SAX parser"); - } - - // xmlFilter1 uses the XMLReader as its reader. - xmlfilter.setParent(parser); - return xmlfilter; - } else { - throw new FOPException("Your parser doesn't support the features SAXSource and SAXResult." - + "\nMake sure you are using a xsl parser which supports TrAX"); - } - } catch (Exception ex) { - if (ex instanceof FOPException) { - throw (FOPException)ex; - } - throw new FOPException(ex); - } - } - -} - diff --git a/src/org/apache/fop/apps/XSLTInputHandler.java b/src/org/apache/fop/apps/XSLTInputHandler.java deleted file mode 100644 index 3b035838a..000000000 --- a/src/org/apache/fop/apps/XSLTInputHandler.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.apps; - -import java.lang.reflect.*; - - -// Imported SAX classes -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; - -// Imported java.io classes -import java.io.*; - -// FOP -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.tools.xslt.XSLTransform; - -/** - * XSLTInputHandler basically takes an xmlfile and transforms it with an xsltfile - * and the resulting xsl:fo document is input for Fop. - */ -public class XSLTInputHandler extends InputHandler { - - File xmlfile, xsltfile; - boolean useOldTransform = false; - - public XSLTInputHandler(File xmlfile, File xsltfile) { - this.xmlfile = xmlfile; - this.xsltfile = xsltfile; - } - - /** - * overwrites the method of the super class to return the xmlfile - */ - public InputSource getInputSource() { - if (useOldTransform) { - try { - java.io.Writer writer; - java.io.Reader reader; - File tmpFile = null; - - // create a Writer - // the following is an ugly hack to allow processing of larger files - // if xml file size is larger than 500 kb write the fo:file to disk - if ((xmlfile.length()) > 500000) { - tmpFile = new File(xmlfile.getName() + ".fo.tmp"); - writer = new FileWriter(tmpFile); - } else { - writer = new StringWriter(); - } - - XSLTransform.transform(xmlfile.getCanonicalPath(), - xsltfile.getCanonicalPath(), writer); - - writer.flush(); - writer.close(); - - if (tmpFile != null) { - reader = new FileReader(tmpFile); - } else { - // create a input source containing the xsl:fo file which can be fed to Fop - reader = new StringReader(writer.toString()); - } - return new InputSource(reader); - } catch (Exception ex) { - ex.printStackTrace(); - return null; - } - } else { - return fileInputSource(xmlfile); - } - - } - - /** - * This looks to see if the Trax api is supported and uses that to - * get an XMLFilter. Otherwise, it falls back to using DOM documents - * - */ - public XMLReader getParser() throws FOPException { - XMLReader result = null; - try { - // try trax first - Class transformer = - Class.forName("javax.xml.transform.Transformer"); - transformer = - Class.forName("org.apache.fop.apps.TraxInputHandler"); - Class[] argTypes = { - File.class, File.class - }; - Method getFilterMethod = transformer.getMethod("getXMLFilter", - argTypes); - File[] args = { - xmlfile, xsltfile - }; - Object obj = getFilterMethod.invoke(null, args); - if (obj instanceof XMLReader) { - result = (XMLReader)obj; - } - } catch (ClassNotFoundException ex) { - throw new FOPException(ex); - } catch (InvocationTargetException ex) { - throw new FOPException(ex); - } catch (IllegalAccessException ex) { - throw new FOPException(ex); - } catch (NoSuchMethodException ex) { - throw new FOPException(ex); - } - // otherwise, use DOM documents via our XSLTransform tool class old style - if (result == null) { - useOldTransform = true; - result = createParser(); - } - return result; - - } - -} - diff --git a/src/org/apache/fop/apps/XTDriver.java b/src/org/apache/fop/apps/XTDriver.java deleted file mode 100644 index 5a0e5f1fb..000000000 --- a/src/org/apache/fop/apps/XTDriver.java +++ /dev/null @@ -1,337 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.apps; - -// FOP -import org.apache.fop.fo.XTFOTreeBuilder; -import org.apache.fop.fo.ElementMapping; -import org.apache.fop.fo.PropertyListMapping; -import org.apache.fop.layout.AreaTree; -import org.apache.fop.layout.FontInfo; -import org.apache.fop.render.Renderer; -import org.apache.fop.messaging.MessageHandler; - -// DOM -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Attr; - -// SAX -import org.xml.sax.DocumentHandler; -import org.xml.sax.InputSource; -import org.xml.sax.Parser; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.AttributesImpl; - -// Java -import java.io.*; - -/** - *

Primary class that drives overall FOP process. - * - *

Once this class is instantiated, methods are called to set the - * Renderer to use, the (possibly multiple) ElementMapping(s) to - * use and the PrintWriter to use to output the results of the - * rendering (where applicable). In the case of the Renderer and - * ElementMapping(s), the Driver may be supplied either with the - * object itself, or the name of the class, in which case Driver will - * instantiate the class itself. The advantage of the latter is it - * enables runtime determination of Renderer and ElementMapping(s). - * - *

Once the Driver is set up, the buildFOTree method - * is called. Depending on whether DOM or SAX is being used, the - * invocation of the method is either buildFOTree(Document) or - * buildFOTree(Parser, InputSource) respectively. - * - *

A third possibility may be used to build the FO Tree, namely - * calling getDocumentHandler() and firing the SAX events yourself. - * - *

Once the FO Tree is built, the format() and render() methods may be - * called in that order. - * - *

Here is an example use of Driver from CommandLine.java: - * - *

- * Driver driver = new Driver();
- * driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer", version);
- * driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
- * driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
- * driver.setWriter(new PrintWriter(new FileWriter(args[1])));
- * driver.buildFOTree(parser, fileInputSource(args[0]));
- * driver.format();
- * driver.render();
- * 
- */ -public class XTDriver { - - /** - * the FO tree builder - */ - protected XTFOTreeBuilder treeBuilder; - - /** - * the area tree that is the result of formatting the FO tree - */ - protected AreaTree areaTree; - - /** - * the renderer to use to output the area tree - */ - protected Renderer renderer; - - /** - * the PrintWriter to use to output the results of the renderer - */ - protected PrintWriter writer; - - /** - * the stream to use to output the results of the renderer - */ - protected OutputStream stream; - - /** - * create a new Driver - */ - public XTDriver() { - this.treeBuilder = new XTFOTreeBuilder(); - } - - /** - * set the Renderer to use - */ - public void setRenderer(Renderer renderer) { - this.renderer = renderer; - } - - /** - * set the class name of the Renderer to use as well as the - * producer string for those renderers that can make use of it - */ - public void setRenderer(String rendererClassName, String producer) { - this.renderer = createRenderer(rendererClassName); - this.renderer.setProducer(producer); - } - - /** - * protected method used by setRenderer(String, String) to - * instantiate the Renderer class - */ - protected Renderer createRenderer(String rendererClassName) { - MessageHandler.logln("using renderer " + rendererClassName); - - try { - return (Renderer)Class.forName(rendererClassName).newInstance(); - } catch (ClassNotFoundException e) { - MessageHandler.errorln("Could not find " + rendererClassName); - } catch (InstantiationException e) { - MessageHandler.errorln("Could not instantiate " - + rendererClassName); - } catch (IllegalAccessException e) { - MessageHandler.errorln("Could not access " + rendererClassName); - } catch (ClassCastException e) { - MessageHandler.errorln(rendererClassName + " is not a renderer"); - } - return null; - } - - /** - * add the given element mapping. - * - * an element mapping maps element names to Java classes - */ - public void addElementMapping(ElementMapping mapping) { - mapping.addToBuilder(this.treeBuilder); - } - - /** - * add the element mapping with the given class name - */ - public void addElementMapping(String mappingClassName) { - createElementMapping(mappingClassName).addToBuilder(this.treeBuilder); - } - - /** - * protected method used by addElementMapping(String) to - * instantiate element mapping class - */ - protected ElementMapping createElementMapping(String mappingClassName) { - MessageHandler.logln("using element mapping " + mappingClassName); - - try { - return (ElementMapping)Class.forName(mappingClassName).newInstance(); - } catch (ClassNotFoundException e) { - MessageHandler.errorln("Could not find " + mappingClassName); - } catch (InstantiationException e) { - MessageHandler.errorln("Could not instantiate " - + mappingClassName); - } catch (IllegalAccessException e) { - MessageHandler.errorln("Could not access " + mappingClassName); - } catch (ClassCastException e) { - MessageHandler.errorln(mappingClassName - + " is not an element mapping"); - } - return null; - } - - /** - * return the tree builder (a SAX DocumentHandler). - * - * used in situations where SAX is used but not via a FOP-invoked - * SAX parser. A good example is an XSLT engine that fires SAX - * events but isn't a SAX Parser itself. - */ - public DocumentHandler getDocumentHandler() { - return this.treeBuilder; - } - - /** - * build the formatting object tree using the given SAX Parser and - * SAX InputSource - */ - public void buildFOTree(Parser parser, - InputSource source) throws FOPException { - - parser.setDocumentHandler(this.treeBuilder); - try { - parser.parse(source); - } catch (SAXException e) { - if (e.getException() instanceof FOPException) - throw (FOPException)e.getException(); - else - throw new FOPException(e.getMessage()); - } catch (IOException e) { - throw new FOPException(e.getMessage()); - } - } - - /** - * build the formatting object tree using the given DOM Document - */ - public void buildFOTree(Document document) throws FOPException { - - /* most of this code is modified from John Cowan's */ - - Node currentNode; - AttributesImpl currentAtts; - - /* temporary array for making Strings into character arrays */ - char[] array = null; - - currentAtts = new AttributesImpl(); - - /* start at the document element */ - currentNode = document; - - try { - while (currentNode != null) { - switch (currentNode.getNodeType()) { - case Node.DOCUMENT_NODE: - this.treeBuilder.startDocument(); - break; - case Node.CDATA_SECTION_NODE: - case Node.TEXT_NODE: - String data = currentNode.getNodeValue(); - int datalen = data.length(); - if (array == null || array.length < datalen) { - /* - * if the array isn't big enough, make a new - * one - */ - array = new char[datalen]; - } - data.getChars(0, datalen, array, 0); - this.treeBuilder.characters(array, 0, datalen); - break; - case Node.PROCESSING_INSTRUCTION_NODE: - this.treeBuilder.processingInstruction(currentNode.getNodeName(), - currentNode.getNodeValue()); - break; - case Node.ELEMENT_NODE: - NamedNodeMap map = currentNode.getAttributes(); - currentAtts.clear(); - for (int i = map.getLength() - 1; i >= 0; i--) { - Attr att = (Attr)map.item(i); - currentAtts.addAttribute("", att.getName(), "", - "CDATA", att.getValue()); - } - this.treeBuilder.startElement("", - currentNode.getNodeName(), - "", currentAtts); - break; - } - - Node nextNode = currentNode.getFirstChild(); - if (nextNode != null) { - currentNode = nextNode; - continue; - } - - while (currentNode != null) { - switch (currentNode.getNodeType()) { - case Node.DOCUMENT_NODE: - this.treeBuilder.endDocument(); - break; - case Node.ELEMENT_NODE: - this.treeBuilder.endElement("", - currentNode.getNodeName(), - ""); - break; - } - - nextNode = currentNode.getNextSibling(); - if (nextNode != null) { - currentNode = nextNode; - break; - } - - currentNode = currentNode.getParentNode(); - } - } - } catch (SAXException e) { - throw new FOPException(e.getMessage()); - } - } - - /** - * set the PrintWriter to use to output the result of the Renderer - * (if applicable) - */ - public void setWriter(PrintWriter writer) { - this.writer = writer; - } - - /** - * set the OutputStream to use to output the result of the Renderer - * (if applicable) - */ - public void setOutputStream(OutputStream stream) { - this.stream = stream; - } - - /** - * format the formatting object tree into an area tree - */ - public void format() throws FOPException { - FontInfo fontInfo = new FontInfo(); - this.renderer.setupFontInfo(fontInfo); - - this.areaTree = new AreaTree(); - this.areaTree.setFontInfo(fontInfo); - - this.treeBuilder.format(areaTree); - } - - /** - * render the area tree to the output form - */ - public void render() throws IOException, FOPException { - this.renderer.render(areaTree, this.stream); - } - -} diff --git a/src/org/apache/fop/fo/flow/BasicLink.java b/src/org/apache/fop/fo/flow/BasicLink.java deleted file mode 100644 index c06c507c8..000000000 --- a/src/org/apache/fop/fo/flow/BasicLink.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.apps.FOPException; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.datatypes.ColorType; - -// Java -import java.util.Enumeration; -import java.awt.Rectangle; - -public class BasicLink extends FObjMixed { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new BasicLink(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new BasicLink.Maker(); - } - - public BasicLink(FObj parent, - PropertyList propertyList) throws FOPException { - super(parent, propertyList); - this.name = "fo:basic-link"; - - if (parent.getName().equals("fo:flow")) { - throw new FOPException("basic-link can't be directly" - + " under flow"); - } - } - - public Status layout(Area area) throws FOPException { - String destination; - int linkType; - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Margin Properties-Inline - MarginInlineProps mProps = propMgr.getMarginInlineProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("alignment-adjust"); - // this.properties.get("alignment-baseline"); - // this.properties.get("baseline-shift"); - // this.properties.get("destination-place-offset"); - // this.properties.get("dominant-baseline"); - // this.properties.get("external-destination"); - // this.properties.get("id"); - // this.properties.get("indicate-destination"); - // this.properties.get("internal-destination"); - // this.properties.get("keep-together"); - // this.properties.get("keep-with-next"); - // this.properties.get("keep-with-previous"); - // this.properties.get("line-height"); - // this.properties.get("line-height-shift-adjustment"); - // this.properties.get("show-destination"); - // this.properties.get("target-processing-context"); - // this.properties.get("target-presentation-context"); - // this.properties.get("target-stylesheet"); - - if (!(destination = - this.properties.get("internal-destination").getString()).equals("")) { - linkType = LinkSet.INTERNAL; - } else if (!(destination = - this.properties.get("external-destination").getString()).equals("")) { - linkType = LinkSet.EXTERNAL; - } else { - throw new FOPException("internal-destination or external-destination must be specified in basic-link"); - } - - if (this.marker == START) { - // initialize id - String id = this.properties.get("id").getString(); - area.getIDReferences().initializeID(id, area); - this.marker = 0; - } - - // new LinkedArea to gather up inlines - LinkSet ls = new LinkSet(destination, area, linkType); - - Page p = area.getPage(); - - AreaContainer ac = p.getBody().getCurrentColumnArea(); - if (ac == null) { - throw new FOPException("Couldn't get ancestor AreaContainer when processing basic-link"); - } - - int numChildren = this.children.size(); - for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode)children.elementAt(i); - fo.setLinkSet(ls); - - Status status; - if ((status = fo.layout(area)).isIncomplete()) { - this.marker = i; - return status; - } - } - - ls.applyAreaContainerOffsets(ac, area); - - // pass on command line - String mergeLinks = System.getProperty("links.merge"); - if ((null != mergeLinks) &&!mergeLinks.equalsIgnoreCase("no")) { - ls.mergeLinks(); - } - - p.addLinkSet(ls); - - return new Status(Status.OK); - } - -} diff --git a/src/org/apache/fop/fo/flow/BidiOverride.java b/src/org/apache/fop/fo/flow/BidiOverride.java deleted file mode 100644 index ea1566cc7..000000000 --- a/src/org/apache/fop/fo/flow/BidiOverride.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.layout.*; -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.fo.flow.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.AreaTree; -import org.apache.fop.apps.FOPException; - -/** - */ -public class BidiOverride extends ToBeImplementedElement { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new BidiOverride(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new BidiOverride.Maker(); - } - - protected BidiOverride(FObj parent, - PropertyList propertyList) throws FOPException { - super(parent, propertyList); - this.name = "fo:bidi-override"; - } - - public Status layout(Area area) throws FOPException { - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Font Properties - //this.fontState = propMgr.getFontState(area.getFontInfo()); - - // Common Margin Properties-Inline - RelativePositionProps mProps = propMgr.getRelativePositionProps(); - - // this.properties.get("color"); - // this.properties.get("direction"); - // this.properties.get("id"); - // this.properties.get("letter-spacing"); - // this.properties.get("line-height"); - // this.properties.get("line-height-shift-adjustment"); - // this.properties.get("score-spaces"); - // this.properties.get("text-shadow"); - // this.properties.get("text-transform"); - // this.properties.get("unicode-bidi"); - // this.properties.get("word-spacing"); - - return super.layout(area); - } -} diff --git a/src/org/apache/fop/fo/flow/Block.java b/src/org/apache/fop/fo/flow/Block.java deleted file mode 100644 index 7ba0bed04..000000000 --- a/src/org/apache/fop/fo/flow/Block.java +++ /dev/null @@ -1,363 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.datatypes.*; -import org.apache.fop.apps.FOPException; - -/* - Modified by Mark Lillywhite mark-fop@inomial.com. The changes - here are based on memory profiling and do not change functionality. - Essentially, the Block object had a pointer to a BlockArea object - that it created. The BlockArea was not referenced after the Block - was finished except to determine the size of the BlockArea, however - a reference to the BlockArea was maintained and this caused a lot of - GC problems, and was a major reason for FOP memory leaks. So, - the reference to BlockArea was made local, the required information - is now stored (instead of a reference to the complex BlockArea object) - and it appears that there are a lot of changes in this file, in fact - there are only a few sematic changes; mostly I just got rid of - "this." from blockArea since BlockArea is now local. - */ - -public class Block extends FObjMixed { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new Block(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new Block.Maker(); - } - - int align; - int alignLast; - int breakAfter; - int lineHeight; - int startIndent; - int endIndent; - int spaceBefore; - int spaceAfter; - int textIndent; - int keepWithNext; - ColorType backgroundColor; - int blockWidows; - int blockOrphans; - - int areaHeight = 0; - int contentWidth = 0; - - String id; - int span; - - // this may be helpful on other FOs too - boolean anythingLaidOut = false; - - public Block(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:block"; - this.span = this.properties.get("span").getEnum(); - } - - public Status layout(Area area) throws FOPException { - BlockArea blockArea; - - // MessageHandler.error(" b:LAY[" + marker + "] "); - - - if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); - } - - if (this.marker == START) { - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Font Properties - //this.fontState = propMgr.getFontState(area.getFontInfo()); - - // Common Hyphenation Properties - HyphenationProps mHyphProps = propMgr.getHyphenationProps(); - - // Common Margin Properties-Block - MarginProps mProps = propMgr.getMarginProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("break-after"); - // this.properties.get("break-before"); - // this.properties.get("color"); - // this.properties.get("text-depth"); - // this.properties.get("text-altitude"); - // this.properties.get("hyphenation-keep"); - // this.properties.get("hyphenation-ladder-count"); - // this.properties.get("id"); - // this.properties.get("keep-together"); - // this.properties.get("keep-with-next"); - // this.properties.get("keep-with-previous"); - // this.properties.get("last-line-end-indent"); - // this.properties.get("linefeed-treatment"); - // this.properties.get("line-height"); - // this.properties.get("line-height-shift-adjustment"); - // this.properties.get("line-stacking-strategy"); - // this.properties.get("orphans"); - // this.properties.get("space-treatment"); - // this.properties.get("span"); - // this.properties.get("text-align"); - // this.properties.get("text-align-last"); - // this.properties.get("text-indent"); - // this.properties.get("visibility"); - // this.properties.get("white-space-collapse"); - // this.properties.get("widows"); - // this.properties.get("wrap-option"); - // this.properties.get("z-index"); - - this.align = this.properties.get("text-align").getEnum(); - this.alignLast = this.properties.get("text-align-last").getEnum(); - this.breakAfter = this.properties.get("break-after").getEnum(); - this.lineHeight = - this.properties.get("line-height").getLength().mvalue(); - this.startIndent = - this.properties.get("start-indent").getLength().mvalue(); - this.endIndent = - this.properties.get("end-indent").getLength().mvalue(); - this.spaceBefore = - this.properties.get("space-before.optimum").getLength().mvalue(); - this.spaceAfter = - this.properties.get("space-after.optimum").getLength().mvalue(); - this.textIndent = - this.properties.get("text-indent").getLength().mvalue(); - this.keepWithNext = - this.properties.get("keep-with-next").getEnum(); - this.backgroundColor = - this.properties.get("background-color").getColorType(); - - this.blockWidows = - this.properties.get("widows").getNumber().intValue(); - this.blockOrphans = - this.properties.get("orphans").getNumber().intValue(); - - - - this.id = this.properties.get("id").getString(); - - if (area instanceof BlockArea) { - area.end(); - } - - if (area.getIDReferences() != null) - area.getIDReferences().createID(id); - - this.marker = 0; - - // no break if first in area tree, or leading in context - // area - int breakBeforeStatus = propMgr.checkBreakBefore(area); - if (breakBeforeStatus != Status.OK) { - return new Status(breakBeforeStatus); - } - - int numChildren = this.children.size(); - for (int i = 0; i < numChildren; i++) { - FONode fo = (FONode)children.elementAt(i); - if (fo instanceof FOText) { - if (((FOText)fo).willCreateArea()) { - fo.setWidows(blockWidows); - break; - } else { - children.removeElementAt(i); - numChildren = this.children.size(); - i--; - } - } else { - fo.setWidows(blockWidows); - break; - } - } - - for (int i = numChildren - 1; i >= 0; i--) { - FONode fo = (FONode)children.elementAt(i); - if (fo instanceof FOText) { - if (((FOText)fo).willCreateArea()) { - fo.setOrphans(blockOrphans); - break; - } - } else { - fo.setOrphans(blockOrphans); - break; - } - } - } - - if ((spaceBefore != 0) && (this.marker == 0)) { - area.addDisplaySpace(spaceBefore); - } - - if (anythingLaidOut) { - this.textIndent = 0; - } - - if (marker == 0 && area.getIDReferences() != null) { - area.getIDReferences().configureID(id, area); - } - - int spaceLeft = area.spaceLeft(); - blockArea = - new BlockArea(propMgr.getFontState(area.getFontInfo()), - area.getAllocationWidth(), area.spaceLeft(), - startIndent, endIndent, textIndent, align, - alignLast, lineHeight); - blockArea.setGeneratedBy(this); - this.areasGenerated++; - if (this.areasGenerated == 1) - blockArea.isFirst(true); - // for normal areas this should be the only pair - blockArea.addLineagePair(this, this.areasGenerated); - - // markers - if (this.hasMarkers()) - blockArea.addMarkers(this.getMarkers()); - - blockArea.setParent(area); // BasicLink needs it - blockArea.setPage(area.getPage()); - blockArea.setBackgroundColor(backgroundColor); - blockArea.setBorderAndPadding(propMgr.getBorderAndPadding()); - blockArea.setHyphenation(propMgr.getHyphenationProps()); - blockArea.start(); - - blockArea.setAbsoluteHeight(area.getAbsoluteHeight()); - blockArea.setIDReferences(area.getIDReferences()); - - blockArea.setTableCellXOffset(area.getTableCellXOffset()); - - int numChildren = this.children.size(); - for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode)children.elementAt(i); - Status status; - if ((status = fo.layout(blockArea)).isIncomplete()) { - this.marker = i; - // this block was modified by - // Hani Elabed 11/27/2000 - // if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) - // { - // status = new Status(Status.AREA_FULL_SOME); - // } - - // new block to replace the one above - // Hani Elabed 11/27/2000 - if (status.getCode() == Status.AREA_FULL_NONE) { - // something has already been laid out - if ((i != 0)) { - status = new Status(Status.AREA_FULL_SOME); - area.addChild(blockArea); - area.setMaxHeight(area.getMaxHeight() - spaceLeft - + blockArea.getMaxHeight()); - area.increaseHeight(blockArea.getHeight()); - area.setAbsoluteHeight(blockArea.getAbsoluteHeight()); - anythingLaidOut = true; - - return status; - } else // i == 0 nothing was laid out.. - { - anythingLaidOut = false; - return status; - } - } - - // blockArea.end(); - area.addChild(blockArea); - area.setMaxHeight(area.getMaxHeight() - spaceLeft - + blockArea.getMaxHeight()); - area.increaseHeight(blockArea.getHeight()); - area.setAbsoluteHeight(blockArea.getAbsoluteHeight()); - anythingLaidOut = true; - return status; - } - anythingLaidOut = true; - } - - blockArea.end(); - - area.setMaxHeight(area.getMaxHeight() - spaceLeft - + blockArea.getMaxHeight()); - - area.addChild(blockArea); - - /* should this be combined into above? */ - area.increaseHeight(blockArea.getHeight()); - - area.setAbsoluteHeight(blockArea.getAbsoluteHeight()); - - if (spaceAfter != 0) { - area.addDisplaySpace(spaceAfter); - } - - if (area instanceof BlockArea) { - area.start(); - } - // This is not needed any more and it consumes a LOT - // of memory. So we release it for the GC. - areaHeight= blockArea.getHeight(); - contentWidth= blockArea.getContentWidth(); - - // no break if last in area tree, or trailing in context - // area - int breakAfterStatus = propMgr.checkBreakAfter(area); - if (breakAfterStatus != Status.OK) { - this.marker = BREAK_AFTER; - blockArea = null; //Faster GC - BlockArea is big - return new Status(breakAfterStatus); - } - - if (keepWithNext != 0) { - blockArea = null; // Faster GC - BlockArea is big - return new Status(Status.KEEP_WITH_NEXT); - } - - // MessageHandler.error(" b:OK" + marker + " "); - blockArea.isLast(true); - blockArea = null; // Faster GC - BlockArea is big - return new Status(Status.OK); - } - - public int getAreaHeight() { - return areaHeight; - } - - - /** - * Return the content width of the boxes generated by this FO. - */ - public int getContentWidth() { - return contentWidth; // getAllocationWidth()?? - } - - - public int getSpan() { - return this.span; - } - -} diff --git a/src/org/apache/fop/fo/flow/BlockContainer.java b/src/org/apache/fop/fo/flow/BlockContainer.java deleted file mode 100644 index 563fbbfcc..000000000 --- a/src/org/apache/fop/fo/flow/BlockContainer.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.fo.pagination.PageSequence; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.*; - -// Java -import java.util.Hashtable; -import java.util.Enumeration; - -public class BlockContainer extends FObj { - - ColorType backgroundColor; - int position; - - int top; - int bottom; - int left; - int right; - int width; - int height; - - int span; - - AreaContainer areaContainer; - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new BlockContainer(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new BlockContainer.Maker(); - } - - PageSequence pageSequence; - - protected BlockContainer(FObj parent, - PropertyList propertyList) throws FOPException { - super(parent, propertyList); - this.name = "fo:block-container"; - this.span = this.properties.get("span").getEnum(); - } - - public Status layout(Area area) throws FOPException { - if (this.marker == START) { - - // Common Accessibility Properties - AbsolutePositionProps mAbsProps = propMgr.getAbsolutePositionProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Margin-Block Properties - MarginProps mProps = propMgr.getMarginProps(); - - // this.properties.get("block-progression-dimension"); - // this.properties.get("break-after"); - // this.properties.get("break-before"); - // this.properties.get("clip"); - // this.properties.get("display-align"); - // this.properties.get("height"); - // this.properties.get("id"); - // this.properties.get("keep-together"); - // this.properties.get("keep-with-next"); - // this.properties.get("keep-with-previous"); - // this.properties.get("overflow"); - // this.properties.get("reference-orientation"); - // this.properties.get("span"); - // this.properties.get("width"); - // this.properties.get("writing-mode"); - - this.marker = 0; - - this.backgroundColor = - this.properties.get("background-color").getColorType(); - - this.position = this.properties.get("position").getEnum(); - this.top = this.properties.get("top").getLength().mvalue(); - this.bottom = this.properties.get("bottom").getLength().mvalue(); - this.left = this.properties.get("left").getLength().mvalue(); - this.right = this.properties.get("right").getLength().mvalue(); - this.width = this.properties.get("width").getLength().mvalue(); - this.height = this.properties.get("height").getLength().mvalue(); - span = this.properties.get("span").getEnum(); - - // initialize id - String id = this.properties.get("id").getString(); - area.getIDReferences().initializeID(id, area); - } - - boolean prevChildMustKeepWithNext = false; - - AreaContainer container = (AreaContainer)area; - if ((this.width == 0) && (this.height == 0)) { - width = right - left; - height = bottom - top; - } - - this.areaContainer = - new AreaContainer(propMgr.getFontState(container.getFontInfo()), - container.getXPosition() + left, - container.getYPosition() - top, width, height, - position); - - areaContainer.setPage(area.getPage()); - areaContainer.setBackgroundColor(backgroundColor); - areaContainer.setBorderAndPadding(propMgr.getBorderAndPadding()); - areaContainer.start(); - - areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); - areaContainer.setIDReferences(area.getIDReferences()); - - int numChildren = this.children.size(); - for (int i = this.marker; i < numChildren; i++) { - FObj fo = (FObj)children.elementAt(i); - Status status; - if ((status = fo.layout(areaContainer)).isIncomplete()) { - /* - * if ((prevChildMustKeepWithNext) && (status.laidOutNone())) { - * this.marker = i - 1; - * FObj prevChild = (FObj) children.elementAt(this.marker); - * prevChild.removeAreas(); - * prevChild.resetMarker(); - * return new Status(Status.AREA_FULL_SOME); - * // should probably return AREA_FULL_NONE if first - * // or perhaps an entirely new status code - * } else { - * this.marker = i; - * return status; - * } - */ - } - if (status.getCode() == Status.KEEP_WITH_NEXT) { - prevChildMustKeepWithNext = true; - } - } - area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); - - areaContainer.end(); - if (position == Position.ABSOLUTE) - areaContainer.setHeight(height); - area.addChild(areaContainer); - - return new Status(Status.OK); - } - - /** - * Return the content width of the boxes generated by this block - * container FO. - */ - public int getContentWidth() { - if (areaContainer != null) - return areaContainer.getContentWidth(); // getAllocationWidth()?? - else - return 0; // not laid out yet - } - - public boolean generatesReferenceAreas() { - return true; - } - - public int getSpan() { - return this.span; - } - -} diff --git a/src/org/apache/fop/fo/flow/Character.java b/src/org/apache/fop/fo/flow/Character.java deleted file mode 100644 index eea3c77d2..000000000 --- a/src/org/apache/fop/fo/flow/Character.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// fop -import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.datatypes.ColorType; -import org.apache.fop.layout.BlockArea; -import org.apache.fop.layout.*; -import org.apache.fop.layout.inline.InlineArea; -import org.apache.fop.fo.FObj; -import org.apache.fop.layout.FontState; -import org.apache.fop.layout.LineArea; -import org.apache.fop.apps.FOPException; -import org.apache.fop.messaging.MessageHandler; - - -/** - * this class represents the flow object 'fo:character'. Its use is defined by - * the spec: "The fo:character flow object represents a character that is mapped to - * a glyph for presentation. It is an atomic unit to the formatter. - * When the result tree is interpreted as a tree of formatting objects, - * a character in the result tree is treated as if it were an empty - * element of type fo:character with a character attribute - * equal to the Unicode representation of the character. - * The semantics of an "auto" value for character properties, which is - * typically their initial value, are based on the Unicode codepoint. - * Overrides may be specified in an implementation-specific manner." (6.6.3) - * - */ -public class Character extends FObj { - public final static int OK = 0; - public final static int DOESNOT_FIT = 1; - - public Character(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:character"; - } - - public static FObj.Maker maker() { - return new Character.Maker(); - } - - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new Character(parent, propertyList); - } - - } - - - public Status layout(Area area) throws FOPException { - BlockArea blockArea; - if (!(area instanceof BlockArea)) { - MessageHandler.errorln("WARNING: currently Character can only be in a BlockArea"); - return new Status(Status.OK); - } - blockArea = (BlockArea)area; - boolean textDecoration; - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Font Properties - //this.fontState = propMgr.getFontState(area.getFontInfo()); - - // Common Hyphenation Properties - HyphenationProps mHyphProps = propMgr.getHyphenationProps(); - - // Common Margin Properties-Inline - MarginInlineProps mProps = propMgr.getMarginInlineProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("alignment-adjust"); - // this.properties.get("treat-as-word-space"); - // this.properties.get("alignment-baseline"); - // this.properties.get("baseline-shift"); - // this.properties.get("character"); - // this.properties.get("color"); - // this.properties.get("dominant-baseline"); - // this.properties.get("text-depth"); - // this.properties.get("text-altitude"); - // this.properties.get("glyph-orientation-horizontal"); - // this.properties.get("glyph-orientation-vertical"); - // this.properties.get("id"); - // this.properties.get("keep-with-next"); - // this.properties.get("keep-with-previous"); - // this.properties.get("letter-spacing"); - // this.properties.get("line-height"); - // this.properties.get("line-height-shift-adjustment"); - // this.properties.get("score-spaces"); - // this.properties.get("suppress-at-line-break"); - // this.properties.get("text-decoration"); - // this.properties.get("text-shadow"); - // this.properties.get("text-transform"); - // this.properties.get("word-spacing"); - - // color properties - ColorType c = this.properties.get("color").getColorType(); - float red = c.red(); - float green = c.green(); - float blue = c.blue(); - - int whiteSpaceCollapse = - this.properties.get("white-space-collapse").getEnum(); - int wrapOption = this.parent.properties.get("wrap-option").getEnum(); - - int tmp = this.properties.get("text-decoration").getEnum(); - if (tmp == org.apache.fop.fo.properties.TextDecoration.UNDERLINE) { - textDecoration = true; - } else { - textDecoration = false; - } - - // Character specific properties - char characterValue = this.properties.get("character").getCharacter(); - - - // initialize id - String id = this.properties.get("id").getString(); - blockArea.getIDReferences().initializeID(id, blockArea); - - LineArea la = blockArea.getCurrentLineArea(); - if (la == null) { - return new Status(Status.AREA_FULL_NONE); - } - la.changeFont(propMgr.getFontState(area.getFontInfo())); - la.changeColor(red, green, blue); - la.changeWrapOption(wrapOption); - la.changeWhiteSpaceCollapse(whiteSpaceCollapse); - blockArea.setupLinkSet(this.getLinkSet()); - int result = la.addCharacter(characterValue, this.getLinkSet(), - textDecoration); - if (result == Character.DOESNOT_FIT) { - la = blockArea.createNextLineArea(); - if (la == null) { - return new Status(Status.AREA_FULL_NONE); - } - la.changeFont(propMgr.getFontState(area.getFontInfo())); - la.changeColor(red, green, blue); - la.changeWrapOption(wrapOption); - la.changeWhiteSpaceCollapse(whiteSpaceCollapse); - blockArea.setupLinkSet(this.getLinkSet()); - la.addCharacter(characterValue, this.getLinkSet(), - textDecoration); - } - return new Status(Status.OK); - - } - -} diff --git a/src/org/apache/fop/fo/flow/ExternalGraphic.java b/src/org/apache/fop/fo/flow/ExternalGraphic.java deleted file mode 100644 index 4647ce846..000000000 --- a/src/org/apache/fop/fo/flow/ExternalGraphic.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; -import org.apache.fop.image.*; - -// Java -import java.util.Enumeration; -import java.util.Hashtable; -import java.net.URL; -import java.net.MalformedURLException; - -public class ExternalGraphic extends FObj { - - int breakAfter; - int breakBefore; - int align; - int startIndent; - int endIndent; - int spaceBefore; - int spaceAfter; - String src; - int height; - int width; - String id; - - ImageArea imageArea; - - - public ExternalGraphic(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:external-graphic"; - } - - - public Status layout(Area area) throws FOPException { - - if (this.marker == START) { - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Margin Properties-Inline - MarginInlineProps mProps = propMgr.getMarginInlineProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("alignment-adjust"); - // this.properties.get("alignment-baseline"); - // this.properties.get("baseline-shift"); - // this.properties.get("block-progression-dimension"); - // this.properties.get("content-height"); - // this.properties.get("content-type"); - // this.properties.get("content-width"); - // this.properties.get("display-align"); - // this.properties.get("dominant-baseline"); - // this.properties.get("height"); - // this.properties.get("id"); - // this.properties.get("inline-progression-dimension"); - // this.properties.get("keep-with-next"); - // this.properties.get("keep-with-previous"); - // this.properties.get("line-height"); - // this.properties.get("line-height-shift-adjustment"); - // this.properties.get("overflow"); - // this.properties.get("scaling"); - // this.properties.get("scaling-method"); - // this.properties.get("src"); - // this.properties.get("text-align"); - // this.properties.get("width"); - - // FIXME - this.align = this.properties.get("text-align").getEnum(); - - this.startIndent = - this.properties.get("start-indent").getLength().mvalue(); - this.endIndent = - this.properties.get("end-indent").getLength().mvalue(); - - this.spaceBefore = - this.properties.get("space-before.optimum").getLength().mvalue(); - this.spaceAfter = - this.properties.get("space-after.optimum").getLength().mvalue(); - - this.src = this.properties.get("src").getString(); - - this.width = this.properties.get("width").getLength().mvalue(); - - this.height = this.properties.get("height").getLength().mvalue(); - - this.id = this.properties.get("id").getString(); - - area.getIDReferences().createID(id); - /* - * if (area instanceof BlockArea) { - * area.end(); - * } - * if (this.isInTableCell) { - * startIndent += forcedStartOffset; - * endIndent = area.getAllocationWidth() - forcedWidth - - * forcedStartOffset; - * } - */ - this.marker = 0; - } - - try { - FopImage img = FopImageFactory.Make(src); - // if width / height needs to be computed - if ((width == 0) || (height == 0)) { - // aspect ratio - double imgWidth = img.getWidth(); - double imgHeight = img.getHeight(); - if ((width == 0) && (height == 0)) { - width = (int)((imgWidth * 1000d)); - height = (int)((imgHeight * 1000d)); - } else if (height == 0) { - height = (int)((imgHeight * ((double)width)) / imgWidth); - } else if (width == 0) { - width = (int)((imgWidth * ((double)height)) / imgHeight); - } - } - - // scale image if it doesn't fit in the area/page - // Need to be more tested... - double ratio = ((double)width) / ((double)height); - int areaWidth = area.getAllocationWidth() - startIndent - - endIndent; - int pageHeight = area.getPage().getHeight(); - if (height > pageHeight) { - height = pageHeight; - width = (int)(ratio * ((double)height)); - } - if (width > areaWidth) { - width = areaWidth; - height = (int)(((double)width) / ratio); - } - - if (area.spaceLeft() < (height + spaceBefore)) { - return new Status(Status.AREA_FULL_NONE); - } - - this.imageArea = - new ImageArea(propMgr.getFontState(area.getFontInfo()), img, - area.getAllocationWidth(), width, height, - startIndent, endIndent, align); - - if ((spaceBefore != 0) && (this.marker == 0)) { - area.addDisplaySpace(spaceBefore); - } - - if (marker == 0) { - // configure id - area.getIDReferences().configureID(id, area); - } - - imageArea.start(); - imageArea.end(); - // area.addChild(imageArea); - // area.increaseHeight(imageArea.getHeight()); - - if (spaceAfter != 0) { - area.addDisplaySpace(spaceAfter); - } - if (breakBefore == BreakBefore.PAGE - || ((spaceBefore + imageArea.getHeight()) - > area.spaceLeft())) { - return new Status(Status.FORCE_PAGE_BREAK); - } - - if (breakBefore == BreakBefore.ODD_PAGE) { - return new Status(Status.FORCE_PAGE_BREAK_ODD); - } - - if (breakBefore == BreakBefore.EVEN_PAGE) { - return new Status(Status.FORCE_PAGE_BREAK_EVEN); - } - - - if (area instanceof BlockArea) { - BlockArea ba = (BlockArea)area; - LineArea la = ba.getCurrentLineArea(); - if (la == null) { - return new Status(Status.AREA_FULL_NONE); - } - la.addPending(); - if (imageArea.getContentWidth() > la.getRemainingWidth()) { - la = ba.createNextLineArea(); - if (la == null) { - return new Status(Status.AREA_FULL_NONE); - } - } - la.addInlineArea(imageArea); - } else { - area.addChild(imageArea); - area.increaseHeight(imageArea.getContentHeight()); - } - imageArea.setPage(area.getPage()); - - if (breakAfter == BreakAfter.PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK); - } - - if (breakAfter == BreakAfter.ODD_PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_ODD); - } - - if (breakAfter == BreakAfter.EVEN_PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_EVEN); - } - - - - - - } catch (MalformedURLException urlex) { - // bad URL - MessageHandler.errorln("Error while creating area : " - + urlex.getMessage()); - } catch (FopImageException imgex) { - // image error - MessageHandler.errorln("Error while creating area : " - + imgex.getMessage()); - } - - // if (area instanceof BlockArea) { - // area.start(); - // } - - return new Status(Status.OK); - } - - - public static FObj.Maker maker() { - return new ExternalGraphic.Maker(); - } - - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new ExternalGraphic(parent, propertyList); - } - - } -} - diff --git a/src/org/apache/fop/fo/flow/Float.java b/src/org/apache/fop/fo/flow/Float.java deleted file mode 100644 index c5eb15188..000000000 --- a/src/org/apache/fop/fo/flow/Float.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.fo.flow.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; - -/** - */ -public class Float extends ToBeImplementedElement { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new Float(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new Float.Maker(); - } - - protected Float(FObj parent, - PropertyList propertyList) throws FOPException { - super(parent, propertyList); - this.name = "fo:float"; - } - - public Status layout(Area area) throws FOPException { - - // this.properties.get("float"); - // this.properties.get("clear"); - - return super.layout(area); - } -} diff --git a/src/org/apache/fop/fo/flow/Flow.java b/src/org/apache/fop/fo/flow/Flow.java deleted file mode 100644 index 9f90dca51..000000000 --- a/src/org/apache/fop/fo/flow/Flow.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.fo.pagination.*; -import org.apache.fop.layout.Area; -import org.apache.fop.layout.BodyAreaContainer; -import org.apache.fop.apps.FOPException; -import org.apache.fop.messaging.MessageHandler; - -// Java -import java.util.Hashtable; -import java.util.Enumeration; -import java.util.Vector; - -public class Flow extends FObj { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new Flow(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new Flow.Maker(); - } - - /** - * PageSequence container - */ - private PageSequence pageSequence; - - /** - * Area in which we lay out our kids - */ - private Area area; - - /** - * Vector to store snapshot - */ - private Vector markerSnapshot; - - /** - * flow-name attribute - */ - private String _flowName; - - private Status _status = new Status(Status.AREA_FULL_NONE); - - - protected Flow(FObj parent, - PropertyList propertyList) throws FOPException { - super(parent, propertyList); - this.name = getElementName(); - - if (parent.getName().equals("fo:page-sequence")) { - this.pageSequence = (PageSequence)parent; - } else { - throw new FOPException("flow must be child of " - + "page-sequence, not " - + parent.getName()); - } - setFlowName(getProperty("flow-name").getString()); - - // according to communication from Paul Grosso (XSL-List, - // 001228, Number 406), confusion in spec section 6.4.5 about - // multiplicity of fo:flow in XSL 1.0 is cleared up - one (1) - // fo:flow per fo:page-sequence only. - - if (pageSequence.isFlowSet()) { - if (this.name.equals("fo:flow")) { - throw new FOPException("Only a single fo:flow permitted" - + " per fo:page-sequence"); - } else { - throw new FOPException(this.name - + " not allowed after fo:flow"); - } - } - pageSequence.addFlow(this); - } - - protected void setFlowName(String name) throws FOPException { - if (name == null || name.equals("")) { - MessageHandler.errorln("WARNING: A 'flow-name' is required for " - + getElementName() - + ". This constraint will be enforced in future versions of FOP"); - _flowName = "xsl-region-body"; - } else { - _flowName = name; - } - - } - - public String getFlowName() { - return _flowName; - } - - public Status layout(Area area) throws FOPException { - return layout(area, null); - - } - - public Status layout(Area area, Region region) throws FOPException { - if (this.marker == START) { - this.marker = 0; - } - - // flow is *always* laid out into a BodyAreaContainer - BodyAreaContainer bac = (BodyAreaContainer)area; - - boolean prevChildMustKeepWithNext = false; - Vector pageMarker = this.getMarkerSnapshot(new Vector()); - - int numChildren = this.children.size(); - if (numChildren == 0) { - throw new FOPException("fo:flow must contain block-level children"); - } - for (int i = this.marker; i < numChildren; i++) { - FObj fo = (FObj)children.elementAt(i); - - if (bac.isBalancingRequired(fo)) { - // reset the the just-done span area in preparation - // for a backtrack for balancing - bac.resetSpanArea(); - - this.rollback(markerSnapshot); - // one less because of the "continue" - i = this.marker - 1; - continue; - } - // current column area - Area currentArea = bac.getNextArea(fo); - // temporary hack for IDReferences - currentArea.setIDReferences(bac.getIDReferences()); - if (bac.isNewSpanArea()) { - this.marker = i; - markerSnapshot = this.getMarkerSnapshot(new Vector()); - } - - _status = fo.layout(currentArea); - - /* - * if((_status.isPageBreak() || i == numChildren - 1) && bac.needsFootnoteAdjusting()) { - * bac.adjustFootnoteArea(); - * this.rollback(pageMarker); - * i = this.marker - 1; - * Area mainReferenceArea = bac.getMainReferenceArea(); - * // remove areas - * continue; - * } - */ - if (_status.isIncomplete()) { - if ((prevChildMustKeepWithNext) && (_status.laidOutNone())) { - this.marker = i - 1; - FObj prevChild = (FObj)children.elementAt(this.marker); - prevChild.removeAreas(); - prevChild.resetMarker(); - prevChild.removeID(area.getIDReferences()); - _status = new Status(Status.AREA_FULL_SOME); - return _status; - // should probably return AREA_FULL_NONE if first - // or perhaps an entirely new status code - } - if (bac.isLastColumn()) - if (_status.getCode() == Status.FORCE_COLUMN_BREAK) { - this.marker = i; - _status = - new Status(Status.FORCE_PAGE_BREAK); // same thing - return _status; - } else { - this.marker = i; - return _status; - } - else { - // not the last column, but could be page breaks - if (_status.isPageBreak()) { - this.marker = i; - return _status; - } - // I don't much like exposing this. (AHS 001217) - ((org.apache.fop.layout.ColumnArea)currentArea).incrementSpanIndex(); - i--; - } - } - if (_status.getCode() == Status.KEEP_WITH_NEXT) { - prevChildMustKeepWithNext = true; - } else { - prevChildMustKeepWithNext = false; - } - } - return _status; - } - - /** - * Return the content width of this flow (really of the region - * in which it is flowing). - */ - public int getContentWidth() { - if (area != null) - return area.getContentWidth(); // getAllocationWidth()?? - else - return 0; // not laid out yet - } - - protected String getElementName() { - return "fo:flow"; - } - - public Status getStatus() { - return _status; - } - - - public boolean generatesReferenceAreas() { - return true; - } - -} diff --git a/src/org/apache/fop/fo/flow/Footnote.java b/src/org/apache/fop/fo/flow/Footnote.java deleted file mode 100644 index 3f72d49fb..000000000 --- a/src/org/apache/fop/fo/flow/Footnote.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; -import org.apache.fop.fo.properties.*; -import org.apache.fop.messaging.*; - -// Java -import java.util.Enumeration; -import java.util.Vector; - -public class Footnote extends FObj { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new Footnote(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new Footnote.Maker(); - } - - public Footnote(FObj parent, - PropertyList propertyList) throws FOPException { - super(parent, propertyList); - this.name = "fo:footnote"; - } - - public Status layout(Area area) throws FOPException { - FONode inline = null; - FONode fbody = null; - if (this.marker == START) { - this.marker = 0; - } - int numChildren = this.children.size(); - for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode)children.elementAt(i); - if (fo instanceof Inline) { - inline = fo; - Status status = fo.layout(area); - if (status.isIncomplete()) { - return status; - } - } else if (inline != null && fo instanceof FootnoteBody) { - // add footnote to current page or next if it can't fit - fbody = fo; - if (area instanceof BlockArea) { - ((BlockArea)area).addFootnote((FootnoteBody)fbody); - } else { - Page page = area.getPage(); - layoutFootnote(page, (FootnoteBody)fbody, area); - } - } - } - if (fbody == null) { - MessageHandler.errorln("WARNING: no footnote-body in footnote"); - } - if (area instanceof BlockArea) {} - return new Status(Status.OK); - } - - public static boolean layoutFootnote(Page p, FootnoteBody fb, Area area) { - try { - BodyAreaContainer bac = p.getBody(); - AreaContainer footArea = bac.getFootnoteReferenceArea(); - footArea.setIDReferences(bac.getIDReferences()); - int basePos = footArea.getCurrentYPosition() - - footArea.getHeight(); - int oldHeight = footArea.getHeight(); - if (area != null) { - footArea.setMaxHeight(area.getMaxHeight() - area.getHeight() - + footArea.getHeight()); - } else { - footArea.setMaxHeight(bac.getMaxHeight() - + footArea.getHeight()); - } - Status status = fb.layout(footArea); - if (status.isIncomplete()) { - // add as a pending footnote - return false; - } else { - if (area != null) { - area.setMaxHeight(area.getMaxHeight() - - footArea.getHeight() + oldHeight); - } - // bac.setMaxHeight(bac.getMaxHeight() - footArea.getHeight() + oldHeight); - if (bac.getFootnoteState() == 0) { - Area ar = bac.getMainReferenceArea(); - decreaseMaxHeight(ar, footArea.getHeight() - oldHeight); - footArea.setYPosition(basePos + footArea.getHeight()); - } - } - } catch (FOPException fope) { - return false; - } - return true; - } - - protected static void decreaseMaxHeight(Area ar, int change) { - ar.setMaxHeight(ar.getMaxHeight() - change); - Vector childs = ar.getChildren(); - for (Enumeration en = childs.elements(); en.hasMoreElements(); ) { - Object obj = en.nextElement(); - if (obj instanceof Area) { - Area childArea = (Area)obj; - decreaseMaxHeight(childArea, change); - } - } - } - -} diff --git a/src/org/apache/fop/fo/flow/FootnoteBody.java b/src/org/apache/fop/fo/flow/FootnoteBody.java deleted file mode 100644 index 029ea5b92..000000000 --- a/src/org/apache/fop/fo/flow/FootnoteBody.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.layout.Area; -import org.apache.fop.layout.AreaClass; -import org.apache.fop.apps.FOPException; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; - -// Java -import java.util.Enumeration; - -public class FootnoteBody extends FObj { - - int align; - int alignLast; - int lineHeight; - int startIndent; - int endIndent; - int textIndent; - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new FootnoteBody(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new FootnoteBody.Maker(); - } - - public FootnoteBody(FObj parent, - PropertyList propertyList) throws FOPException { - super(parent, propertyList); - this.name = "fo:footnote-body"; - this.areaClass = AreaClass.setAreaClass(AreaClass.XSL_FOOTNOTE); - } - - public Status layout(Area area) throws FOPException { - if (this.marker == START) { - this.marker = 0; - } - BlockArea blockArea = - new BlockArea(propMgr.getFontState(area.getFontInfo()), - area.getAllocationWidth(), area.spaceLeft(), - startIndent, endIndent, textIndent, align, - alignLast, lineHeight); - blockArea.setGeneratedBy(this); - blockArea.isFirst(true); - blockArea.setPage(area.getPage()); - blockArea.start(); - - blockArea.setAbsoluteHeight(area.getAbsoluteHeight()); - blockArea.setIDReferences(area.getIDReferences()); - - blockArea.setTableCellXOffset(area.getTableCellXOffset()); - - int numChildren = this.children.size(); - for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode)children.elementAt(i); - Status status; - if ((status = fo.layout(blockArea)).isIncomplete()) { - this.resetMarker(); - return status; - } - } - blockArea.end(); - area.addChild(blockArea); - area.increaseHeight(blockArea.getHeight()); - blockArea.isLast(true); - return new Status(Status.OK); - } - -} diff --git a/src/org/apache/fop/fo/flow/InitialPropertySet.java b/src/org/apache/fop/fo/flow/InitialPropertySet.java deleted file mode 100644 index 7406146d2..000000000 --- a/src/org/apache/fop/fo/flow/InitialPropertySet.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.layout.*; -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.fo.flow.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.AreaTree; -import org.apache.fop.apps.FOPException; - -/** - */ -public class InitialPropertySet extends ToBeImplementedElement { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new InitialPropertySet(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new InitialPropertySet.Maker(); - } - - protected InitialPropertySet(FObj parent, PropertyList propertyList) - throws FOPException { - super(parent, propertyList); - this.name = "fo:initial-property-set"; - } - - public Status layout(Area area) throws FOPException { - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Font Properties - //this.fontState = propMgr.getFontState(area.getFontInfo()); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("color"); - // this.properties.get("id"); - // this.properties.get("letter-spacing"); - // this.properties.get("line-height"); - // this.properties.get("line-height-shift-adjustment"); - // this.properties.get("score-spaces"); - // this.properties.get("text-decoration"); - // this.properties.get("text-shadow"); - // this.properties.get("text-transform"); - // this.properties.get("word-spacing"); - - return super.layout(area); - } -} diff --git a/src/org/apache/fop/fo/flow/Inline.java b/src/org/apache/fop/fo/flow/Inline.java deleted file mode 100644 index 100bb4947..000000000 --- a/src/org/apache/fop/fo/flow/Inline.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; -import org.apache.fop.fo.properties.*; - -// Java -import java.util.Enumeration; - -public class Inline extends FObjMixed { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new Inline(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new Inline.Maker(); - } - - // Textdecoration - protected boolean underlined = false; - protected boolean overlined = false; - protected boolean lineThrough = false; - - - public Inline(FObj parent, - PropertyList propertyList) throws FOPException { - super(parent, propertyList); - this.name = "fo:inline"; - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Font Properties - //this.fontState = propMgr.getFontState(area.getFontInfo()); - - // Common Margin Properties-Inline - MarginInlineProps mProps = propMgr.getMarginInlineProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("alignment-adjust"); - // this.properties.get("alignment-baseline"); - // this.properties.get("baseline-shift"); - // this.properties.get("color"); - // this.properties.get("dominant-baseline"); - // this.properties.get("id"); - // this.properties.get("keep-together"); - // this.properties.get("keep-with-next"); - // this.properties.get("keep-with-previous"); - // this.properties.get("line-height"); - // this.properties.get("line-height-shift-adjustment"); - // this.properties.get("text-devoration"); - // this.properties.get("visibility"); - // this.properties.get("z-index"); - - int textDecoration = this.properties.get("text-decoration").getEnum(); - - if (textDecoration == TextDecoration.UNDERLINE) { - this.underlined = true; - } - - if (textDecoration == TextDecoration.OVERLINE) { - this.overlined = true; - } - - if (textDecoration == TextDecoration.LINE_THROUGH) { - this.lineThrough = true; - } - - if (parent.getName().equals("fo:flow")) { - throw new FOPException("fo:inline can't be directly" - + " under flow"); - } - - } - - protected void addCharacters(char data[], int start, int length) { - FOText ft = new FOText(data, start, length, this); - ft.setUnderlined(underlined); - ft.setOverlined(overlined); - ft.setLineThrough(lineThrough); - children.addElement(ft); - } - -} diff --git a/src/org/apache/fop/fo/flow/InlineContainer.java b/src/org/apache/fop/fo/flow/InlineContainer.java deleted file mode 100644 index 5332a2dc6..000000000 --- a/src/org/apache/fop/fo/flow/InlineContainer.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.fo.flow.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; - -/** - */ -public class InlineContainer extends ToBeImplementedElement { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new InlineContainer(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new InlineContainer.Maker(); - } - - protected InlineContainer(FObj parent, - PropertyList propertyList) throws FOPException { - super(parent, propertyList); - this.name = "fo:inline-container"; - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Margin Properties-Inline - MarginInlineProps mProps = propMgr.getMarginInlineProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("alignment-adjust"); - // this.properties.get("alignment-baseline"); - // this.properties.get("baseline-shift"); - // this.properties.get("block-progression-dimension"); - // this.properties.get("clip"); - // this.properties.get("display-align"); - // this.properties.get("dominant-baseline"); - // this.properties.get("height"); - // this.properties.get("id"); - // this.properties.get("inline-progression-dimension"); - // this.properties.get("keep-together"); - // this.properties.get("keep-with-next"); - // this.properties.get("keep-with-previous"); - // this.properties.get("line-height"); - // this.properties.get("line-height-shift-adjustment"); - // this.properties.get("overflow"); - // this.properties.get("reference-orientation"); - // this.properties.get("width"); - // this.properties.get("writing-mode"); - } - -} diff --git a/src/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/org/apache/fop/fo/flow/InstreamForeignObject.java deleted file mode 100644 index 27f9dc1c4..000000000 --- a/src/org/apache/fop/fo/flow/InstreamForeignObject.java +++ /dev/null @@ -1,299 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.layout.inline.*; -import org.apache.fop.layout.BlockArea; -import org.apache.fop.layout.FontState; -import org.apache.fop.apps.FOPException; - -// Java -import java.util.Enumeration; - -public class InstreamForeignObject extends FObj { - - /** - * inner class for making SVG objects. - */ - public static class Maker extends FObj.Maker { - - /** - * make an SVG object. - * - * @param parent the parent formatting object - * @param propertyList the explicit properties of this object - * - * @return the SVG object - */ - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new InstreamForeignObject(parent, propertyList); - } - - } - - /** - * returns the maker for this object. - * - * @return the maker for SVG objects - */ - public static FObj.Maker maker() { - return new InstreamForeignObject.Maker(); - } - - int breakBefore; - int breakAfter; - int scaling; - int width; - int height; - int contwidth; - int contheight; - boolean wauto; - boolean hauto; - boolean cwauto; - boolean chauto; - int spaceBefore; - int spaceAfter; - int startIndent; - int endIndent; - - ForeignObjectArea areaCurrent; - - /** - * constructs an instream-foreign-object object (called by Maker). - * - * @param parent the parent formatting object - * @param propertyList the explicit properties of this object - */ - public InstreamForeignObject(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:instream-foreign-object"; - } - - /** - * layout this formatting object. - * - * @param area the area to layout the object into - * - * @return the status of the layout - */ - public Status layout(Area area) throws FOPException { - - if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); - } - - if (this.marker == START) { - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Margin Properties-Inline - MarginInlineProps mProps = propMgr.getMarginInlineProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("alignment-adjust"); - // this.properties.get("alignment-baseline"); - // this.properties.get("baseline-shift"); - // this.properties.get("block-progression-dimension"); - // this.properties.get("content-height"); - // this.properties.get("content-type"); - // this.properties.get("content-width"); - // this.properties.get("display-align"); - // this.properties.get("dominant-baseline"); - // this.properties.get("height"); - // this.properties.get("id"); - // this.properties.get("inline-progression-dimension"); - // this.properties.get("keep-with-next"); - // this.properties.get("keep-with-previous"); - // this.properties.get("line-height"); - // this.properties.get("line-height-shift-adjustment"); - // this.properties.get("overflow"); - // this.properties.get("scaling"); - // this.properties.get("scaling-method"); - // this.properties.get("text-align"); - // this.properties.get("width"); - - /* retrieve properties */ - String id = this.properties.get("id").getString(); - int align = this.properties.get("text-align").getEnum(); - int valign = this.properties.get("vertical-align").getEnum(); - int overflow = this.properties.get("overflow").getEnum(); - - this.breakBefore = this.properties.get("break-before").getEnum(); - this.breakAfter = this.properties.get("break-after").getEnum(); - this.width = this.properties.get("width").getLength().mvalue(); - this.height = this.properties.get("height").getLength().mvalue(); - this.contwidth = - this.properties.get("content-width").getLength().mvalue(); - this.contheight = - this.properties.get("content-height").getLength().mvalue(); - this.wauto = this.properties.get("width").getLength().isAuto(); - this.hauto = this.properties.get("height").getLength().isAuto(); - this.cwauto = - this.properties.get("content-width").getLength().isAuto(); - this.chauto = - this.properties.get("content-height").getLength().isAuto(); - - this.startIndent = - this.properties.get("start-indent").getLength().mvalue(); - this.endIndent = - this.properties.get("end-indent").getLength().mvalue(); - this.spaceBefore = - this.properties.get("space-before.optimum").getLength().mvalue(); - this.spaceAfter = - this.properties.get("space-after.optimum").getLength().mvalue(); - - this.scaling = this.properties.get("scaling").getEnum(); - - area.getIDReferences().createID(id); - if (this.areaCurrent == null) { - this.areaCurrent = - new ForeignObjectArea(propMgr.getFontState(area.getFontInfo()), - area.getAllocationWidth()); - - this.areaCurrent.start(); - areaCurrent.setWidth(this.width); - areaCurrent.setHeight(this.height); - areaCurrent.setContentWidth(this.contwidth); - areaCurrent.setContentHeight(this.contheight); - areaCurrent.setScaling(this.scaling); - areaCurrent.setAlign(align); - areaCurrent.setVerticalAlign(valign); - areaCurrent.setOverflow(overflow); - areaCurrent.setSizeAuto(wauto, hauto); - areaCurrent.setContentSizeAuto(cwauto, chauto); - - // this means that children can get the fontstate - areaCurrent.setPage(area.getPage()); - - int numChildren = this.children.size(); - if (numChildren > 1) { - throw new FOPException("Only one child element is allowed in an instream-foreign-object"); - } - /* layout foreign object */ - if (this.children.size() > 0) { - FONode fo = (FONode)children.elementAt(0); - Status status; - // currently FONode must be an SVG - if ((status = - fo.layout(this.areaCurrent)).isIncomplete()) { - return status; - } - - /* finish off the foreign object area */ - this.areaCurrent.end(); - } - } - - this.marker = 0; - - if (breakBefore == BreakBefore.PAGE - || ((spaceBefore + areaCurrent.getEffectiveHeight()) - > area.spaceLeft())) { - return new Status(Status.FORCE_PAGE_BREAK); - } - - if (breakBefore == BreakBefore.ODD_PAGE) { - return new Status(Status.FORCE_PAGE_BREAK_ODD); - } - - if (breakBefore == BreakBefore.EVEN_PAGE) { - return new Status(Status.FORCE_PAGE_BREAK_EVEN); - } - } - - if (this.areaCurrent == null) { - return new Status(Status.OK); - } - - if (area instanceof BlockArea) { - BlockArea ba = (BlockArea)area; - LineArea la = ba.getCurrentLineArea(); - if (la == null) { - return new Status(Status.AREA_FULL_NONE); - } - la.addPending(); - if (areaCurrent.getEffectiveWidth() > la.getRemainingWidth()) { - la = ba.createNextLineArea(); - if (la == null) { - return new Status(Status.AREA_FULL_NONE); - } - } - la.addInlineArea(areaCurrent); - } else { - area.addChild(areaCurrent); - area.increaseHeight(areaCurrent.getEffectiveHeight()); - } - - if (this.isInTableCell) { - startIndent += forcedStartOffset; - /* - * endIndent = areaCurrent.getEffectiveWidth() - forcedWidth - - * forcedStartOffset; - */ - } - - areaCurrent.setStartIndent(startIndent); - // areaCurrent.setEndIndent(endIndent); - - /* if there is a space-before */ - if (spaceBefore != 0) { - /* add a display space */ - // area.addDisplaySpace(spaceBefore); - } - - /* add the SVG area to the containing area */ - // area.addChild(areaCurrent); - - areaCurrent.setPage(area.getPage()); - - /* increase the height of the containing area accordingly */ - // area.increaseHeight(areaCurrent.getEffectiveHeight()); - - /* if there is a space-after */ - if (spaceAfter != 0) { - /* add a display space */ - // area.addDisplaySpace(spaceAfter); - } - - - if (breakAfter == BreakAfter.PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK); - } - - if (breakAfter == BreakAfter.ODD_PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_ODD); - } - - if (breakAfter == BreakAfter.EVEN_PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_EVEN); - } - - areaCurrent = null; - /* return status */ - return new Status(Status.OK); - } - -} diff --git a/src/org/apache/fop/fo/flow/Leader.java b/src/org/apache/fop/fo/flow/Leader.java deleted file mode 100644 index 97d1e00c8..000000000 --- a/src/org/apache/fop/fo/flow/Leader.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.datatypes.*; -import org.apache.fop.layout.*; -import org.apache.fop.layout.BlockArea; -import org.apache.fop.layout.inline.LeaderArea; -import org.apache.fop.layout.LineArea; -import org.apache.fop.layout.FontState; -import org.apache.fop.apps.FOPException; -import org.apache.fop.messaging.MessageHandler; - -/** - * Implements fo:leader; main property of leader leader-pattern. - * The following patterns are treated: rule, space, dots. - * The pattern use-content is ignored, i.e. it still must be implemented. - */ - -public class Leader extends FObjMixed { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new Leader(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new Leader.Maker(); - } - - public Leader(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:leader"; - } - - public Status layout(Area area) throws FOPException { - BlockArea blockArea; - // restriction in this version - if (!(area instanceof BlockArea)) { - MessageHandler.errorln("WARNING: in this version of Fop fo:leader must be a direct child of fo:block "); - return new Status(Status.OK); - } else { - blockArea = (BlockArea)area; - } - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Font Properties - //this.fontState = propMgr.getFontState(area.getFontInfo()); - - // Common Margin Properties-Inline - MarginInlineProps mProps = propMgr.getMarginInlineProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("alignment-adjust"); - // this.properties.get("alignment-baseline"); - // this.properties.get("baseline-shift"); - // this.properties.get("color"); - // this.properties.get("dominant-baseline"); - // this.properties.get("text-depth"); - // this.properties.get("text-altitude"); - // this.properties.get("id"); - // this.properties.get("leader-alignment"); - // this.properties.get("leader-length"); - // this.properties.get("leader-pattern"); - // this.properties.get("leader-pattern-width"); - // this.properties.get("rule-style"); - // this.properties.get("rule-thickness"); - // this.properties.get("letter-spacing"); - // this.properties.get("line-height"); - // this.properties.get("line-height-shift-adjustment"); - // this.properties.get("text-shadow"); - // this.properties.get("visibility"); - // this.properties.get("word-spacing"); - // this.properties.get("z-index"); - - // color properties - ColorType c = this.properties.get("color").getColorType(); - float red = c.red(); - float green = c.green(); - float blue = c.blue(); - - // fo:leader specific properties - // determines the pattern of leader; allowed values: space, rule,dots, use-content - int leaderPattern = this.properties.get("leader-pattern").getEnum(); - // length of the leader - int leaderLengthOptimum = - this.properties.get("leader-length.optimum").getLength().mvalue(); - int leaderLengthMinimum = - this.properties.get("leader-length.minimum").getLength().mvalue(); - int leaderLengthMaximum = - this.properties.get("leader-length.maximum").getLength().mvalue(); - // the following properties only apply for leader-pattern = "rule" - int ruleThickness = - this.properties.get("rule-thickness").getLength().mvalue(); - int ruleStyle = this.properties.get("rule-style").getEnum(); - // if leaderPatternWidth = 0 = default = use-font-metric - int leaderPatternWidth = - this.properties.get("leader-pattern-width").getLength().mvalue(); - int leaderAlignment = - this.properties.get("leader-alignment").getEnum(); - - // initialize id - String id = this.properties.get("id").getString(); - blockArea.getIDReferences().initializeID(id, blockArea); - - // adds leader to blockarea, there the leaderArea is generated - int succeeded = addLeader(blockArea, - propMgr.getFontState(area.getFontInfo()), - red, green, blue, leaderPattern, - leaderLengthMinimum, leaderLengthOptimum, - leaderLengthMaximum, ruleThickness, - ruleStyle, leaderPatternWidth, - leaderAlignment); - if (succeeded == 1) { - return new Status(Status.OK); - } else { - // not sure that this is the correct Status here - return new Status(Status.AREA_FULL_SOME); - } - } - - /* - * //should only be necessary for use-content - * protected void addCharacters(char data[], int start, int length) { - * FOText textNode = new FOText(data,start,length, this); - * children.addElement(textNode); - * } - */ - - - /** - * adds a leader to current line area of containing block area - * the actual leader area is created in the line area - * - * @return int +1 for success and -1 for none - */ - public int addLeader(BlockArea ba, FontState fontState, float red, - float green, float blue, int leaderPattern, - int leaderLengthMinimum, int leaderLengthOptimum, - int leaderLengthMaximum, int ruleThickness, - int ruleStyle, int leaderPatternWidth, - int leaderAlignment) { - - LineArea la = ba.getCurrentLineArea(); - // this should start a new page - if (la == null) { - return -1; - } - - la.changeFont(fontState); - la.changeColor(red, green, blue); - - // check whether leader fits into the (rest of the) line - // using length.optimum to determine where to break the line as defined - // in the xsl:fo spec: "User agents may choose to use the value of 'leader-length.optimum' - // to determine where to break the line" (7.20.4) - // if leader is longer then create a new LineArea and put leader there - if (leaderLengthOptimum <= (la.getRemainingWidth())) { - la.addLeader(leaderPattern, leaderLengthMinimum, - leaderLengthOptimum, leaderLengthMaximum, ruleStyle, - ruleThickness, leaderPatternWidth, leaderAlignment); - } else { - la = ba.createNextLineArea(); - if (la == null) { - // not enough room - return -1; - } - la.changeFont(fontState); - la.changeColor(red, green, blue); - - // check whether leader fits into LineArea at all, otherwise - // clip it (should honor the clip option of containing area) - if (leaderLengthMinimum <= la.getContentWidth()) { - la.addLeader(leaderPattern, leaderLengthMinimum, - leaderLengthOptimum, leaderLengthMaximum, - ruleStyle, ruleThickness, leaderPatternWidth, - leaderAlignment); - } else { - MessageHandler.errorln("Leader doesn't fit into line, it will be clipped to fit."); - la.addLeader(leaderPattern, la.getRemainingWidth(), - leaderLengthOptimum, leaderLengthMaximum, - ruleStyle, ruleThickness, leaderPatternWidth, - leaderAlignment); - } - } - // this.hasLines = true; - return 1; - } - -} diff --git a/src/org/apache/fop/fo/flow/ListBlock.java b/src/org/apache/fop/fo/flow/ListBlock.java deleted file mode 100644 index 3b93659d3..000000000 --- a/src/org/apache/fop/fo/flow/ListBlock.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.fo.properties.*; -import org.apache.fop.datatypes.*; -import org.apache.fop.layout.*; -import org.apache.fop.layout.BlockArea; -import org.apache.fop.layout.FontState; -import org.apache.fop.apps.FOPException; - -// Java -import java.util.Enumeration; - -public class ListBlock extends FObj { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new ListBlock(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new ListBlock.Maker(); - } - - int align; - int alignLast; - int breakBefore; - int breakAfter; - int lineHeight; - int startIndent; - int endIndent; - int spaceBefore; - int spaceAfter; - int spaceBetweenListRows = 0; - ColorType backgroundColor; - - public ListBlock(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:list-block"; - } - - public Status layout(Area area) throws FOPException { - if (this.marker == START) { - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Margin Properties-Block - MarginProps mProps = propMgr.getMarginProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("break-after"); - // this.properties.get("break-before"); - // this.properties.get("id"); - // this.properties.get("keep-together"); - // this.properties.get("keep-with-next"); - // this.properties.get("keep-with-previous"); - // this.properties.get("provisional-distance-between-starts"); - // this.properties.get("provisional-label-separation"); - - this.align = this.properties.get("text-align").getEnum(); - this.alignLast = this.properties.get("text-align-last").getEnum(); - this.lineHeight = - this.properties.get("line-height").getLength().mvalue(); - this.startIndent = - this.properties.get("start-indent").getLength().mvalue(); - this.endIndent = - this.properties.get("end-indent").getLength().mvalue(); - this.spaceBefore = - this.properties.get("space-before.optimum").getLength().mvalue(); - this.spaceAfter = - this.properties.get("space-after.optimum").getLength().mvalue(); - this.spaceBetweenListRows = 0; // not used at present - this.backgroundColor = - this.properties.get("background-color").getColorType(); - - this.marker = 0; - - if (area instanceof BlockArea) { - area.end(); - } - - if (spaceBefore != 0) { - area.addDisplaySpace(spaceBefore); - } - - if (this.isInTableCell) { - startIndent += forcedStartOffset; - endIndent += area.getAllocationWidth() - forcedWidth - - forcedStartOffset; - } - - // initialize id - String id = this.properties.get("id").getString(); - area.getIDReferences().initializeID(id, area); - } - - BlockArea blockArea = - new BlockArea(propMgr.getFontState(area.getFontInfo()), - area.getAllocationWidth(), area.spaceLeft(), - startIndent, endIndent, 0, align, alignLast, - lineHeight); - blockArea.setGeneratedBy(this); - this.areasGenerated++; - if (this.areasGenerated == 1) - blockArea.isFirst(true); - // for normal areas this should be the only pair - blockArea.addLineagePair(this, this.areasGenerated); - - // markers - if (this.hasMarkers()) - blockArea.addMarkers(this.getMarkers()); - - - blockArea.setPage(area.getPage()); - blockArea.setBackgroundColor(backgroundColor); - blockArea.start(); - - blockArea.setAbsoluteHeight(area.getAbsoluteHeight()); - blockArea.setIDReferences(area.getIDReferences()); - - int numChildren = this.children.size(); - for (int i = this.marker; i < numChildren; i++) { - if (!(children.elementAt(i) instanceof ListItem)) { - MessageHandler.errorln("children of list-blocks must be list-items"); - return new Status(Status.OK); - } - ListItem listItem = (ListItem)children.elementAt(i); - Status status; - if ((status = listItem.layout(blockArea)).isIncomplete()) { - if (status.getCode() == Status.AREA_FULL_NONE && i > 0) { - status = new Status(Status.AREA_FULL_SOME); - } - this.marker = i; - blockArea.end(); - area.addChild(blockArea); - area.increaseHeight(blockArea.getHeight()); - area.setAbsoluteHeight(blockArea.getAbsoluteHeight()); - return status; - } - } - - blockArea.end(); - area.addChild(blockArea); - area.increaseHeight(blockArea.getHeight()); - area.setAbsoluteHeight(blockArea.getAbsoluteHeight()); - - if (spaceAfter != 0) { - area.addDisplaySpace(spaceAfter); - } - - if (area instanceof BlockArea) { - area.start(); - } - - blockArea.isLast(true); - return new Status(Status.OK); - } - -} diff --git a/src/org/apache/fop/fo/flow/ListItem.java b/src/org/apache/fop/fo/flow/ListItem.java deleted file mode 100644 index 683a2b024..000000000 --- a/src/org/apache/fop/fo/flow/ListItem.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.layout.BlockArea; -import org.apache.fop.layout.FontState; -import org.apache.fop.apps.FOPException; - -// Java -import java.util.Enumeration; - -public class ListItem extends FObj { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new ListItem(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new ListItem.Maker(); - } - - int align; - int alignLast; - int breakBefore; - int breakAfter; - int lineHeight; - int startIndent; - int endIndent; - int spaceBefore; - int spaceAfter; - String id; - BlockArea blockArea; - - public ListItem(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:list-item"; - } - - public Status layout(Area area) throws FOPException { - if (this.marker == START) { - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Margin Properties-Block - MarginProps mProps = propMgr.getMarginProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("break-after"); - // this.properties.get("break-before"); - // this.properties.get("id"); - // this.properties.get("keep-together"); - // this.properties.get("keep-with-next"); - // this.properties.get("keep-with-previous"); - // this.properties.get("relative-align"); - - this.align = this.properties.get("text-align").getEnum(); - this.alignLast = this.properties.get("text-align-last").getEnum(); - this.lineHeight = - this.properties.get("line-height").getLength().mvalue(); - this.spaceBefore = - this.properties.get("space-before.optimum").getLength().mvalue(); - this.spaceAfter = - this.properties.get("space-after.optimum").getLength().mvalue(); - this.id = this.properties.get("id").getString(); - - area.getIDReferences().createID(id); - - this.marker = 0; - } - - /* not sure this is needed given we know area is from list block */ - if (area instanceof BlockArea) { - area.end(); - } - - if (spaceBefore != 0) { - area.addDisplaySpace(spaceBefore); - } - - this.blockArea = - new BlockArea(propMgr.getFontState(area.getFontInfo()), - area.getAllocationWidth(), area.spaceLeft(), 0, 0, - 0, align, alignLast, lineHeight); - this.blockArea.setGeneratedBy(this); - this.areasGenerated++; - if (this.areasGenerated == 1) - this.blockArea.isFirst(true); - // for normal areas this should be the only pair - this.blockArea.addLineagePair(this, this.areasGenerated); - - // markers - if (this.hasMarkers()) - this.blockArea.addMarkers(this.getMarkers()); - - blockArea.setPage(area.getPage()); - blockArea.start(); - - blockArea.setAbsoluteHeight(area.getAbsoluteHeight()); - blockArea.setIDReferences(area.getIDReferences()); - - int numChildren = this.children.size(); - if (numChildren != 2) { - throw new FOPException("list-item must have exactly two children"); - } - ListItemLabel label = (ListItemLabel)children.elementAt(0); - ListItemBody body = (ListItemBody)children.elementAt(1); - - Status status; - - // what follows doesn't yet take into account whether the - // body failed completely or only got some text in - - if (this.marker == 0) { - // configure id - area.getIDReferences().configureID(id, area); - - status = label.layout(blockArea); - if (status.isIncomplete()) { - return status; - } - } - - status = body.layout(blockArea); - if (status.isIncomplete()) { - blockArea.end(); - area.addChild(blockArea); - area.increaseHeight(blockArea.getHeight()); - area.setAbsoluteHeight(blockArea.getAbsoluteHeight()); - this.marker = 1; - return status; - } - - blockArea.end(); - area.addChild(blockArea); - area.increaseHeight(blockArea.getHeight()); - area.setAbsoluteHeight(blockArea.getAbsoluteHeight()); - - if (spaceAfter != 0) { - area.addDisplaySpace(spaceAfter); - } - - /* not sure this is needed given we know area is from list block */ - if (area instanceof BlockArea) { - area.start(); - } - this.blockArea.isLast(true); - return new Status(Status.OK); - } - - /** - * Return the content width of the boxes generated by this FO. - */ - public int getContentWidth() { - if (blockArea != null) - return blockArea.getContentWidth(); // getAllocationWidth()?? - else - return 0; // not laid out yet - } - -} diff --git a/src/org/apache/fop/fo/flow/ListItemBody.java b/src/org/apache/fop/fo/flow/ListItemBody.java deleted file mode 100644 index fa00c4b4d..000000000 --- a/src/org/apache/fop/fo/flow/ListItemBody.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.layout.FontState; -import org.apache.fop.apps.FOPException; - -// Java -import java.util.Enumeration; - -public class ListItemBody extends FObj { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new ListItemBody(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new ListItemBody.Maker(); - } - - public ListItemBody(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:list-item-body"; - } - - public Status layout(Area area) throws FOPException { - if (this.marker == START) { - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // this.properties.get("id"); - // this.properties.get("keep-together"); - - this.marker = 0; - // initialize id - String id = this.properties.get("id").getString(); - area.getIDReferences().initializeID(id, area); - } - - /* - * For calculating the lineage - The fo:list-item-body formatting object - * does not generate any areas. The fo:list-item-body formatting object - * returns the sequence of areas created by concatenating the sequences - * of areas returned by each of the children of the fo:list-item-body. - */ - - int numChildren = this.children.size(); - for (int i = this.marker; i < numChildren; i++) { - FObj fo = (FObj)children.elementAt(i); - - Status status; - if ((status = fo.layout(area)).isIncomplete()) { - this.marker = i; - if ((i == 0) && (status.getCode() == Status.AREA_FULL_NONE)) { - return new Status(Status.AREA_FULL_NONE); - } else { - return new Status(Status.AREA_FULL_SOME); - } - } - } - return new Status(Status.OK); - } - -} diff --git a/src/org/apache/fop/fo/flow/ListItemLabel.java b/src/org/apache/fop/fo/flow/ListItemLabel.java deleted file mode 100644 index a649459d3..000000000 --- a/src/org/apache/fop/fo/flow/ListItemLabel.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.layout.FontState; -import org.apache.fop.apps.FOPException; - -// Java -import java.util.Enumeration; - -public class ListItemLabel extends FObj { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new ListItemLabel(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new ListItemLabel.Maker(); - } - - public ListItemLabel(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:list-item-label"; - } - - public Status layout(Area area) throws FOPException { - int numChildren = this.children.size(); - - if (numChildren != 1) { - throw new FOPException("list-item-label must have exactly one block in this version of FOP"); - } - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // this.properties.get("id"); - // this.properties.get("keep-together"); - - // initialize id - String id = this.properties.get("id").getString(); - area.getIDReferences().initializeID(id, area); - - Block block = (Block)children.elementAt(0); - - /* - * For calculating the lineage - The fo:list-item-label formatting object - * does not generate any areas. The fo:list-item-label formatting object - * returns the sequence of areas created by concatenating the sequences - * of areas returned by each of the children of the fo:list-item-label. - */ - - Status status; - status = block.layout(area); - area.addDisplaySpace(-block.getAreaHeight()); - return status; - } - -} diff --git a/src/org/apache/fop/fo/flow/Marker.java b/src/org/apache/fop/fo/flow/Marker.java deleted file mode 100644 index aba8b54a9..000000000 --- a/src/org/apache/fop/fo/flow/Marker.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.datatypes.*; -import org.apache.fop.apps.FOPException; - -public class Marker extends FObjMixed { - - private String markerClassName; - private Area registryArea; - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new Marker(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new Marker.Maker(); - } - - public Marker(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:marker"; - - // do check to see that 'this' is under fo:flow - - this.markerClassName = - this.properties.get("marker-class-name").getString(); - - // check to ensure that no other marker with same parent - // has this 'marker-class-name' is in addMarker() method - try { - parent.addMarker(this); - } catch (FOPException fopex) { - MessageHandler.error("marker cannot be added to '" + parent - + "'"); - } - } - - public Status layout(Area area) throws FOPException { - // no layout action desired - this.registryArea = area; - area.addMarker(this); - area.getPage().registerMarker(this); - // System.out.println("Marker being registered in area '" + area + "'"); - return new Status(Status.OK); - } - - public Status layoutMarker(Area area) throws FOPException { - if (this.marker == START) - this.marker = 0; - - int numChildren = this.children.size(); - for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode)children.elementAt(i); - - Status status; - if ((status = fo.layout(area)).isIncomplete()) { - this.marker = i; - return status; - } - } - - return new Status(Status.OK); - } - - public String getMarkerClassName() { - return markerClassName; - } - - public Area getRegistryArea() { - return registryArea; - } - -} diff --git a/src/org/apache/fop/fo/flow/MultiCase.java b/src/org/apache/fop/fo/flow/MultiCase.java deleted file mode 100644 index 9cd7a1073..000000000 --- a/src/org/apache/fop/fo/flow/MultiCase.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.fo.flow.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; - -/** - */ -public class MultiCase extends ToBeImplementedElement { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new MultiCase(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new MultiCase.Maker(); - } - - protected MultiCase(FObj parent, - PropertyList propertyList) throws FOPException { - super(parent, propertyList); - this.name = "fo:multi-case"; - } - - public Status layout(Area area) throws FOPException { - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // this.properties.get("id"); - // this.properties.get("starting-state"); - // this.properties.get("case-name"); - // this.properties.get("case-title"); - - return super.layout(area); - } -} diff --git a/src/org/apache/fop/fo/flow/MultiProperties.java b/src/org/apache/fop/fo/flow/MultiProperties.java deleted file mode 100644 index 03a42b289..000000000 --- a/src/org/apache/fop/fo/flow/MultiProperties.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.fo.flow.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; - -/** - */ -public class MultiProperties extends ToBeImplementedElement { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new MultiProperties(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new MultiProperties.Maker(); - } - - protected MultiProperties(FObj parent, - PropertyList propertyList) throws FOPException { - super(parent, propertyList); - this.name = "fo:multi-properties"; - } - - public Status layout(Area area) throws FOPException { - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // this.properties.get("id"); - - return super.layout(area); - } -} diff --git a/src/org/apache/fop/fo/flow/MultiPropertySet.java b/src/org/apache/fop/fo/flow/MultiPropertySet.java deleted file mode 100644 index 7263f702d..000000000 --- a/src/org/apache/fop/fo/flow/MultiPropertySet.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.fo.flow.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; - -/** - */ -public class MultiPropertySet extends ToBeImplementedElement { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new MultiPropertySet(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new MultiPropertySet.Maker(); - } - - protected MultiPropertySet(FObj parent, PropertyList propertyList) - throws FOPException { - super(parent, propertyList); - this.name = "fo:multi-property-set"; - } - - public Status layout(Area area) throws FOPException { - - // this.properties.get("id"); - // this.properties.get("active-state"); - - return super.layout(area); - } -} diff --git a/src/org/apache/fop/fo/flow/MultiSwitch.java b/src/org/apache/fop/fo/flow/MultiSwitch.java deleted file mode 100644 index 42e6e185a..000000000 --- a/src/org/apache/fop/fo/flow/MultiSwitch.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.fo.flow.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; - -/** - */ -public class MultiSwitch extends ToBeImplementedElement { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new MultiSwitch(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new MultiSwitch.Maker(); - } - - protected MultiSwitch(FObj parent, - PropertyList propertyList) throws FOPException { - super(parent, propertyList); - this.name = "fo:multi-switch"; - } - - public Status layout(Area area) throws FOPException { - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // this.properties.get("auto-restore"); - // this.properties.get("id"); - - return super.layout(area); - } -} diff --git a/src/org/apache/fop/fo/flow/MultiToggle.java b/src/org/apache/fop/fo/flow/MultiToggle.java deleted file mode 100644 index 8fce89f14..000000000 --- a/src/org/apache/fop/fo/flow/MultiToggle.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.fo.flow.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; - -/** - */ -public class MultiToggle extends ToBeImplementedElement { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new MultiToggle(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new MultiToggle.Maker(); - } - - protected MultiToggle(FObj parent, - PropertyList propertyList) throws FOPException { - super(parent, propertyList); - this.name = "fo:multi-toggle"; - } - - public Status layout(Area area) throws FOPException { - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // this.properties.get("id"); - // this.properties.get("switch-to"); - - return super.layout(area); - } -} diff --git a/src/org/apache/fop/fo/flow/PageNumber.java b/src/org/apache/fop/fo/flow/PageNumber.java deleted file mode 100644 index ddfb60473..000000000 --- a/src/org/apache/fop/fo/flow/PageNumber.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.layout.*; -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.datatypes.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; - -// Java -import java.util.Enumeration; - -public class PageNumber extends FObj { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new PageNumber(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new PageNumber.Maker(); - } - - float red; - float green; - float blue; - int wrapOption; - int whiteSpaceCollapse; - TextState ts; - - public PageNumber(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:page-number"; - } - - public Status layout(Area area) throws FOPException { - if (!(area instanceof BlockArea)) { - MessageHandler.errorln("WARNING: page-number outside block area"); - return new Status(Status.OK); - } - if (this.marker == START) { - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Font Properties - //this.fontState = propMgr.getFontState(area.getFontInfo()); - - // Common Margin Properties-Inline - MarginInlineProps mProps = propMgr.getMarginInlineProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("alignment-adjust"); - // this.properties.get("alignment-baseline"); - // this.properties.get("baseline-shift"); - // this.properties.get("dominant-baseline"); - // this.properties.get("id"); - // this.properties.get("keep-with-next"); - // this.properties.get("keep-with-previous"); - // this.properties.get("letter-spacing"); - // this.properties.get("line-height"); - // this.properties.get("line-height-shift-adjustment"); - // this.properties.get("score-spaces"); - // this.properties.get("text-decoration"); - // this.properties.get("text-shadow"); - // this.properties.get("text-transform"); - // this.properties.get("word-spacing"); - - ColorType c = this.properties.get("color").getColorType(); - this.red = c.red(); - this.green = c.green(); - this.blue = c.blue(); - - this.wrapOption = this.properties.get("wrap-option").getEnum(); - this.whiteSpaceCollapse = - this.properties.get("white-space-collapse").getEnum(); - ts = new TextState(); - this.marker = 0; - - // initialize id - String id = this.properties.get("id").getString(); - area.getIDReferences().initializeID(id, area); - } - - String p = area.getPage().getFormattedNumber(); - this.marker = FOText.addText((BlockArea)area, - propMgr.getFontState(area.getFontInfo()), - red, green, blue, wrapOption, null, - whiteSpaceCollapse, p.toCharArray(), 0, - p.length(), ts, VerticalAlign.BASELINE); - return new Status(Status.OK); - } - -} diff --git a/src/org/apache/fop/fo/flow/PageNumberCitation.java b/src/org/apache/fop/fo/flow/PageNumberCitation.java deleted file mode 100644 index 95d93b627..000000000 --- a/src/org/apache/fop/fo/flow/PageNumberCitation.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.fo.pagination.*; -import org.apache.fop.datatypes.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; - - -/** - * 6.6.11 fo:page-number-citation - * - * Common Usage: - * The fo:page-number-citation is used to reference the page-number for the page containing the first normal area returned by - * the cited formatting object. - * - * NOTE: - * It may be used to provide the page-numbers in the table of contents, cross-references, and index entries. - * - * Areas: - * The fo:page-number-citation formatting object generates and returns a single normal inline-area. - * Constraints: - * - * The cited page-number is the number of the page containing, as a descendant, the first normal area returned by the - * formatting object with an id trait matching the ref-id trait of the fo:page-number-citation (the referenced formatting - * object). - * - * The cited page-number string is obtained by converting the cited page-number in accordance with the number to string - * conversion properties specified on the ancestor fo:page-sequence of the referenced formatting object. - * - * The child areas of the generated inline-area are the same as the result of formatting a result-tree fragment consisting of - * fo:character flow objects; one for each character in the cited page-number string and with only the "character" property - * specified. - * - * Contents: - * - * EMPTY - * - * The following properties apply to this formatting object: - * - * [7.3 Common Accessibility Properties] - * [7.5 Common Aural Properties] - * [7.6 Common Border, Padding, and Background Properties] - * [7.7 Common Font Properties] - * [7.10 Common Margin Properties-Inline] - * [7.11.1 "alignment-adjust"] - * [7.11.2 "baseline-identifier"] - * [7.11.3 "baseline-shift"] - * [7.11.5 "dominant-baseline"] - * [7.36.2 "id"] - * [7.17.4 "keep-with-next"] - * [7.17.5 "keep-with-previous"] - * [7.14.2 "letter-spacing"] - * [7.13.4 "line-height"] - * [7.13.5 "line-height-shift-adjustment"] - * [7.36.5 "ref-id"] - * [7.18.4 "relative-position"] - * [7.36.6 "score-spaces"] - * [7.14.4 "text-decoration"] - * [7.14.5 "text-shadow"] - * [7.14.6 "text-transform"] - * [7.14.8 "word-spacing"] - */ -public class PageNumberCitation extends FObj { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new PageNumberCitation(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new PageNumberCitation.Maker(); - } - - float red; - float green; - float blue; - int wrapOption; - int whiteSpaceCollapse; - Area area; - String pageNumber; - String refId; - String id; - TextState ts; - - - public PageNumberCitation(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:page-number-citation"; - } - - - public Status layout(Area area) throws FOPException { - if (!(area instanceof BlockArea)) { - MessageHandler.errorln("WARNING: page-number-citation outside block area"); - return new Status(Status.OK); - } - - IDReferences idReferences = area.getIDReferences(); - this.area = area; - if (this.marker == START) { - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Font Properties - //this.fontState = propMgr.getFontState(area.getFontInfo()); - - // Common Margin Properties-Inline - MarginInlineProps mProps = propMgr.getMarginInlineProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("alignment-adjust"); - // this.properties.get("alignment-baseline"); - // this.properties.get("baseline-shift"); - // this.properties.get("dominant-baseline"); - // this.properties.get("id"); - // this.properties.get("keep-with-next"); - // this.properties.get("keep-with-previous"); - // this.properties.get("letter-spacing"); - // this.properties.get("line-height"); - // this.properties.get("line-height-shift-adjustment"); - // this.properties.get("ref-id"); - // this.properties.get("score-spaces"); - // this.properties.get("text-decoration"); - // this.properties.get("text-shadow"); - // this.properties.get("text-transform"); - // this.properties.get("word-spacing"); - - ColorType c = this.properties.get("color").getColorType(); - this.red = c.red(); - this.green = c.green(); - this.blue = c.blue(); - - this.wrapOption = this.properties.get("wrap-option").getEnum(); - this.whiteSpaceCollapse = - this.properties.get("white-space-collapse").getEnum(); - - this.refId = this.properties.get("ref-id").getString(); - - if (this.refId.equals("")) { - throw new FOPException("page-number-citation must contain \"ref-id\""); - } - - // create id - this.id = this.properties.get("id").getString(); - idReferences.createID(id); - ts = new TextState(); - - this.marker = 0; - } - - if (marker == 0) { - idReferences.configureID(id, area); - } - - - pageNumber = idReferences.getPageNumber(refId); - - if (pageNumber != null) { // if we already know the page number - this.marker = - FOText.addText((BlockArea)area, - propMgr.getFontState(area.getFontInfo()), red, - green, blue, wrapOption, null, - whiteSpaceCollapse, pageNumber.toCharArray(), - 0, pageNumber.length(), ts, - VerticalAlign.BASELINE); - } else { // add pageNumberCitation to area to be resolved during rendering - BlockArea blockArea = (BlockArea)area; - LineArea la = blockArea.getCurrentLineArea(); - if (la == null) { - return new Status(Status.AREA_FULL_NONE); - } - la.changeFont(propMgr.getFontState(area.getFontInfo())); - la.changeColor(red, green, blue); - la.changeWrapOption(wrapOption); - la.changeWhiteSpaceCollapse(whiteSpaceCollapse); - /* - * la.changeHyphenation(language, country, hyphenate, - * hyphenationChar, hyphenationPushCharacterCount, - * hyphenationRemainCharacterCount); - */ - - // blockArea.setupLinkSet(null); - la.addPageNumberCitation(refId, null); - this.marker = -1; - } - - - if (this.marker == -1) { - return new Status(Status.OK); - } else { - return new Status(Status.AREA_FULL_NONE); - } - - } - -} - diff --git a/src/org/apache/fop/fo/flow/RetrieveMarker.java b/src/org/apache/fop/fo/flow/RetrieveMarker.java deleted file mode 100644 index 55376ac65..000000000 --- a/src/org/apache/fop/fo/flow/RetrieveMarker.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.datatypes.*; -import org.apache.fop.apps.FOPException; - -// Java -import java.util.Vector; - -public class RetrieveMarker extends FObjMixed { - - private String retrieveClassName; - private int retrievePosition; - private int retrieveBoundary; - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new RetrieveMarker(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new RetrieveMarker.Maker(); - } - - public RetrieveMarker(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:retrieve-marker"; - - this.retrieveClassName = - this.properties.get("retrieve-class-name").getString(); - this.retrievePosition = - this.properties.get("retrieve-position").getEnum(); - this.retrieveBoundary = - this.properties.get("retrieve-boundary").getEnum(); - } - - public Status layout(Area area) throws FOPException { - // locate qualifying areas by 'marker-class-name' and - // 'retrieve-boundary'. Initially we will always check - // the containing page - Page containingPage = area.getPage(); - Marker bestMarker = searchPage(containingPage, true); - - // if marker not yet found, and 'retrieve-boundary' permits, - // search forward by Page - if ((null == bestMarker) - && (retrieveBoundary != RetrieveBoundary.PAGE)) { - // System.out.println("Null bestMarker and searching..."); - Page currentPage = containingPage; - boolean isFirstCall = true; - while (bestMarker == null) { - Page previousPage = locatePreviousPage(currentPage, - retrieveBoundary, - isFirstCall); - isFirstCall = false; - // System.out.println("Previous page = '" + previousPage + "'"); - bestMarker = searchPage(previousPage, false); - currentPage = previousPage; - } - } - - Status status = new Status(Status.AREA_FULL_NONE); - if (null != bestMarker) { - // System.out.println("Laying out marker '" + bestMarker + "' in area '" + area + "'"); - // the 'markers' referred to in this method are internal; they have - // nothing to do with fo:marker - bestMarker.resetMarker(); - status = bestMarker.layoutMarker(area); - } - - return status; - } - - private Marker searchPage(Page page, - boolean isContainingPage) throws FOPException { - Vector pageMarkers = page.getMarkers(); - if (pageMarkers.isEmpty()) { - // System.out.println("No markers on page"); - return null; - } - - // if no longer the containing page (fo:retrieve-marker, or the page - // being processed), grab the last qualifying marker on this one - if (!isContainingPage) { - for (int c = pageMarkers.size(); c > 0; c--) { - Marker currentMarker = (Marker)pageMarkers.elementAt(c - 1); - if (currentMarker.getMarkerClassName().equals(retrieveClassName)) { - return currentMarker; - } - } - } - - // search forward if 'first-starting-within-page' or - // 'first-including-carryover' - if (retrievePosition == RetrievePosition.FIC) { - for (int c = 0; c < pageMarkers.size(); c++) { - Marker currentMarker = (Marker)pageMarkers.elementAt(c); - if (currentMarker.getMarkerClassName().equals(retrieveClassName)) { - return currentMarker; - } - } - - } else if (retrievePosition == RetrievePosition.FSWP) { - for (int c = 0; c < pageMarkers.size(); c++) { - Marker currentMarker = (Marker)pageMarkers.elementAt(c); - if (currentMarker.getMarkerClassName().equals(retrieveClassName)) { - if (currentMarker.getRegistryArea().isFirst()) { - return currentMarker; - } - } - } - - } else if (retrievePosition == RetrievePosition.LSWP) { - for (int c = pageMarkers.size(); c > 0; c--) { - Marker currentMarker = (Marker)pageMarkers.elementAt(c - 1); - if (currentMarker.getMarkerClassName().equals(retrieveClassName)) { - if (currentMarker.getRegistryArea().isFirst()) { - return currentMarker; - } - } - } - - } else if (retrievePosition == RetrievePosition.LEWP) { - for (int c = pageMarkers.size(); c > 0; c--) { - Marker currentMarker = (Marker)pageMarkers.elementAt(c - 1); - if (currentMarker.getMarkerClassName().equals(retrieveClassName)) { - if (currentMarker.getRegistryArea().isLast()) { - return currentMarker; - } - } - } - - } else { - throw new FOPException("Illegal 'retrieve-position' value"); - } - return null; - } - - private Page locatePreviousPage(Page page, int retrieveBoundary, - boolean isFirstCall) { - boolean pageWithinSequence = true; - if (retrieveBoundary == RetrieveBoundary.DOCUMENT) - pageWithinSequence = false; - return page.getAreaTree().getPreviousPage(page, pageWithinSequence, - isFirstCall); - } - -} diff --git a/src/org/apache/fop/fo/flow/RowSpanMgr.java b/src/org/apache/fop/fo/flow/RowSpanMgr.java deleted file mode 100644 index 363963b62..000000000 --- a/src/org/apache/fop/fo/flow/RowSpanMgr.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * -- $Id$ -- - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -import org.apache.fop.layout.Area; -import java.util.Enumeration; - -public class RowSpanMgr { - class SpanInfo { - int cellHeight; - int totalRowHeight; - int rowsRemaining; - // int numCols; // both V and H span - TableCell cell; - - SpanInfo(TableCell cell, int cellHeight, int rowsSpanned) { - this.cell = cell; - this.cellHeight = cellHeight; - this.totalRowHeight = 0; - this.rowsRemaining = rowsSpanned; - } - - /** - * Return the height remaining in the span. - */ - int heightRemaining() { - int hl = cellHeight - totalRowHeight; - return (hl > 0) ? hl : 0; - } - - boolean isInLastRow() { - return (rowsRemaining == 1); - } - - boolean finishRow(int rowHeight) { - totalRowHeight += rowHeight; - if (--rowsRemaining == 0) { - if (cell != null) { - cell.setRowHeight(totalRowHeight); - } - return true; - } else - return false; - } - - } - - private SpanInfo spanInfo[]; - - public RowSpanMgr(int numCols) { - this.spanInfo = new SpanInfo[numCols]; - } - - public void addRowSpan(TableCell cell, int firstCol, int numCols, - int cellHeight, int rowsSpanned) { - spanInfo[firstCol - 1] = new SpanInfo(cell, cellHeight, rowsSpanned); - for (int i = 0; i < numCols - 1; i++) { - spanInfo[firstCol + i] = new SpanInfo(null, cellHeight, - rowsSpanned); // copy! - } - } - - public boolean isSpanned(int colNum) { - return (spanInfo[colNum - 1] != null); - } - - - public TableCell getSpanningCell(int colNum) { - if (spanInfo[colNum - 1] != null) { - return spanInfo[colNum - 1].cell; - } else - return null; - } - - - /** - * Return true if any column has an unfinished vertical span. - */ - public boolean hasUnfinishedSpans() { - for (int i = 0; i < spanInfo.length; i++) { - if (spanInfo[i] != null) - return true; - } - return false; - } - - /** - * Done with a row. - * Any spans with only one row left are done - * This means that we can now set the total height for this cell box - * Loop over all cells with spans and find number of rows remaining - * if rows remaining = 1, set the height on the cell area and - * then remove the cell from the list of spanned cells. For other - * spans, add the rowHeight to the spanHeight. - */ - public void finishRow(int rowHeight) { - for (int i = 0; i < spanInfo.length; i++) { - if (spanInfo[i] != null && spanInfo[i].finishRow(rowHeight)) - spanInfo[i] = null; - } - } - - /** - * If the cell in this column is in the last row of its vertical - * span, return the height left. If it's not in the last row, or if - * the content height <= the content height of the previous rows - * of the span, return 0. - */ - public int getRemainingHeight(int colNum) { - if (spanInfo[colNum - 1] != null) { - return spanInfo[colNum - 1].heightRemaining(); - } else - return 0; - } - - public boolean isInLastRow(int colNum) { - if (spanInfo[colNum - 1] != null) { - return spanInfo[colNum - 1].isInLastRow(); - } else - return false; - } - -} diff --git a/src/org/apache/fop/fo/flow/StaticContent.java b/src/org/apache/fop/fo/flow/StaticContent.java deleted file mode 100644 index e433ef83e..000000000 --- a/src/org/apache/fop/fo/flow/StaticContent.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.fo.pagination.*; -import org.apache.fop.layout.Area; -import org.apache.fop.apps.FOPException; -import org.apache.fop.messaging.MessageHandler; - -// Java -import java.util.Enumeration; - -public class StaticContent extends Flow { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new StaticContent(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new StaticContent.Maker(); - } - - protected StaticContent(FObj parent, - PropertyList propertyList) throws FOPException { - super(parent, propertyList); - ((PageSequence)parent).setIsFlowSet(false); // hacquery of sorts - } - - public Status layout(Area area) throws FOPException { - return layout(area, null); - } - - - public Status layout(Area area, Region region) throws FOPException { - - int numChildren = this.children.size(); - // Set area absolute height so that link rectangles will be drawn correctly in xsl-before and xsl-after - String regionClass = "none"; - if (region != null) { - regionClass = region.getRegionClass(); - } else { - if (getFlowName().equals("xsl-region-before")) { - regionClass = RegionBefore.REGION_CLASS; - } else if (getFlowName().equals("xsl-region-after")) { - regionClass = RegionAfter.REGION_CLASS; - } else if (getFlowName().equals("xsl-region-start")) { - regionClass = RegionStart.REGION_CLASS; - } else if (getFlowName().equals("xsl-region-end")) { - regionClass = RegionEnd.REGION_CLASS; - } - - } - - if (area instanceof org.apache.fop.layout.AreaContainer) - ((org.apache.fop.layout.AreaContainer)area).setAreaName(regionClass); - - if (regionClass.equals(RegionBefore.REGION_CLASS)) { - area.setAbsoluteHeight(-area.getMaxHeight()); - } else if (regionClass.equals(RegionAfter.REGION_CLASS)) { - area.setAbsoluteHeight(area.getPage().getBody().getMaxHeight()); - } - - for (int i = 0; i < numChildren; i++) { - FObj fo = (FObj)children.elementAt(i); - - Status status; - if ((status = fo.layout(area)).isIncomplete()) { - // in fact all should be laid out and clip, error etc depending on 'overflow' - MessageHandler.logln("Warning: Some static content could not fit in the area."); - this.marker = i; - if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) { - status = new Status(Status.AREA_FULL_SOME); - } - return (status); - } - } - resetMarker(); - return new Status(Status.OK); - } - - protected String getElementName() { - return "fo:static-content"; - } - - // flowname checking is more stringient for static content currently - protected void setFlowName(String name) throws FOPException { - if (name == null || name.equals("")) { - throw new FOPException("A 'flow-name' is required for " - + getElementName() + "."); - } else { - super.setFlowName(name); - } - - } - -} diff --git a/src/org/apache/fop/fo/flow/Table.java b/src/org/apache/fop/fo/flow/Table.java deleted file mode 100644 index 4f67da52b..000000000 --- a/src/org/apache/fop/fo/flow/Table.java +++ /dev/null @@ -1,412 +0,0 @@ -/* - * -- $Id$ -- - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.datatypes.*; -import org.apache.fop.apps.FOPException; - -// Java -import java.util.Vector; - -public class Table extends FObj { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new Table(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new Table.Maker(); - } - - int breakBefore; - int breakAfter; - int spaceBefore; - int spaceAfter; - ColorType backgroundColor; - int width; - int height; - String id; - TableHeader tableHeader = null; - TableFooter tableFooter = null; - boolean omitHeaderAtBreak = false; - boolean omitFooterAtBreak = false; - - Vector columns = new Vector(); - int currentColumnNumber = 0; - int bodyCount = 0; - - AreaContainer areaContainer; - - public Table(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:table"; - } - - public Status layout(Area area) throws FOPException { - if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); - } - - if (this.marker == START) { - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Margin Properties-Block - MarginProps mProps = propMgr.getMarginProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("block-progression-dimension"); - // this.properties.get("border-after-precendence"); - // this.properties.get("border-before-precedence"); - // this.properties.get("border-collapse"); - // this.properties.get("border-end-precendence"); - // this.properties.get("border-separation"); - // this.properties.get("border-start-precendence"); - // this.properties.get("break-after"); - // this.properties.get("break-before"); - // this.properties.get("id"); - // this.properties.get("inline-progression-dimension"); - // this.properties.get("height"); - // this.properties.get("keep-together"); - // this.properties.get("keep-with-next"); - // this.properties.get("keep-with-previous"); - // this.properties.get("table-layout"); - // this.properties.get("table-omit-footer-at-break"); - // this.properties.get("table-omit-header-at-break"); - // this.properties.get("width"); - // this.properties.get("writing-mode"); - - this.breakBefore = this.properties.get("break-before").getEnum(); - this.breakAfter = this.properties.get("break-after").getEnum(); - this.spaceBefore = - this.properties.get("space-before.optimum").getLength().mvalue(); - this.spaceAfter = - this.properties.get("space-after.optimum").getLength().mvalue(); - this.backgroundColor = - this.properties.get("background-color").getColorType(); - this.width = this.properties.get("width").getLength().mvalue(); - this.height = this.properties.get("height").getLength().mvalue(); - - this.id = this.properties.get("id").getString(); - - this.omitHeaderAtBreak = - this.properties.get("table-omit-header-at-break").getEnum() - == TableOmitHeaderAtBreak.TRUE; - this.omitFooterAtBreak = - this.properties.get("table-omit-footer-at-break").getEnum() - == TableOmitFooterAtBreak.TRUE; - - if (area instanceof BlockArea) { - area.end(); - } - if (this.areaContainer - == null) { // check if anything was previously laid out - area.getIDReferences().createID(id); - } - - - this.marker = 0; - - if (breakBefore == BreakBefore.PAGE) { - return new Status(Status.FORCE_PAGE_BREAK); - } - - if (breakBefore == BreakBefore.ODD_PAGE) { - return new Status(Status.FORCE_PAGE_BREAK_ODD); - } - - if (breakBefore == BreakBefore.EVEN_PAGE) { - return new Status(Status.FORCE_PAGE_BREAK_EVEN); - } - } - - if ((spaceBefore != 0) && (this.marker == 0)) { - area.addDisplaySpace(spaceBefore); - } - - if (marker == 0 && areaContainer == null) { - // configure id - area.getIDReferences().configureID(id, area); - } - - int spaceLeft = area.spaceLeft(); - this.areaContainer = - new AreaContainer(propMgr.getFontState(area.getFontInfo()), 0, 0, - area.getAllocationWidth(), area.spaceLeft(), - Position.STATIC); - areaContainer.foCreator = this; // G Seshadri - areaContainer.setPage(area.getPage()); - areaContainer.setBackgroundColor(backgroundColor); - areaContainer.setBorderAndPadding(propMgr.getBorderAndPadding()); - areaContainer.start(); - - areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); - areaContainer.setIDReferences(area.getIDReferences()); - - // added by Eric Schaeffer - currentColumnNumber = 0; - int offset = 0; - - boolean addedHeader = false; - boolean addedFooter = false; - int numChildren = this.children.size(); - for (int i = 0; i < numChildren; i++) { - FONode fo = (FONode)children.elementAt(i); - if (fo instanceof TableColumn) { - TableColumn c = (TableColumn)fo; - c.doSetup(areaContainer); - int numColumnsRepeated = c.getNumColumnsRepeated(); - // int currentColumnNumber = c.getColumnNumber(); - - for (int j = 0; j < numColumnsRepeated; j++) { - currentColumnNumber++; - if (currentColumnNumber > columns.size()) { - columns.setSize(currentColumnNumber); - } - columns.setElementAt(c, currentColumnNumber - 1); - c.setColumnOffset(offset); - c.layout(areaContainer); - offset += c.getColumnWidth(); - } - } - } - areaContainer.setAllocationWidth(offset); - - for (int i = this.marker; i < numChildren; i++) { - FONode fo = (FONode)children.elementAt(i); - if (fo instanceof TableHeader) { - if (columns.size() == 0) { - MessageHandler.errorln("WARNING: current implementation of tables requires a table-column for each column, indicating column-width"); - return new Status(Status.OK); - } - tableHeader = (TableHeader)fo; - tableHeader.setColumns(columns); - } else if (fo instanceof TableFooter) { - if (columns.size() == 0) { - MessageHandler.errorln("WARNING: current implementation of tables requires a table-column for each column, indicating column-width"); - return new Status(Status.OK); - } - tableFooter = (TableFooter)fo; - tableFooter.setColumns(columns); - } else if (fo instanceof TableBody) { - if (columns.size() == 0) { - MessageHandler.errorln("WARNING: current implementation of tables requires a table-column for each column, indicating column-width"); - return new Status(Status.OK); - } - Status status; - if (tableHeader != null &&!addedHeader) { - if ((status = - tableHeader.layout(areaContainer)).isIncomplete()) { - return new Status(Status.AREA_FULL_NONE); - } - addedHeader = true; - tableHeader.resetMarker(); - area.setMaxHeight(area.getMaxHeight() - spaceLeft - + this.areaContainer.getMaxHeight()); - } - if (tableFooter != null &&!this.omitFooterAtBreak - &&!addedFooter) { - if ((status = - tableFooter.layout(areaContainer)).isIncomplete()) { - return new Status(Status.AREA_FULL_NONE); - } - addedFooter = true; - tableFooter.resetMarker(); - } - fo.setWidows(widows); - fo.setOrphans(orphans); - ((TableBody)fo).setColumns(columns); - - if ((status = fo.layout(areaContainer)).isIncomplete()) { - this.marker = i; - if (bodyCount == 0 - && status.getCode() == Status.AREA_FULL_NONE) { - if (tableHeader != null) - tableHeader.removeLayout(areaContainer); - if (tableFooter != null) - tableFooter.removeLayout(areaContainer); - resetMarker(); - // status = new Status(Status.AREA_FULL_SOME); - } - // areaContainer.end(); - if (areaContainer.getContentHeight() > 0) { - area.addChild(areaContainer); - area.increaseHeight(areaContainer.getHeight()); - area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); - if (this.omitHeaderAtBreak) { - // remove header, no longer needed - tableHeader = null; - } - if (tableFooter != null &&!this.omitFooterAtBreak) { - // move footer to bottom of area and move up body - ((TableBody)fo).setYPosition(tableFooter.getYPosition()); - tableFooter.setYPosition(tableFooter.getYPosition() - + ((TableBody)fo).getHeight()); - } - setupColumnHeights(); - status = new Status(Status.AREA_FULL_SOME); - } - return status; - } else { - bodyCount++; - } - area.setMaxHeight(area.getMaxHeight() - spaceLeft - + this.areaContainer.getMaxHeight()); - if (tableFooter != null &&!this.omitFooterAtBreak) { - // move footer to bottom of area and move up body - // space before and after footer will make this wrong - ((TableBody)fo).setYPosition(tableFooter.getYPosition()); - tableFooter.setYPosition(tableFooter.getYPosition() - + ((TableBody)fo).getHeight()); - } - } - } - - if (tableFooter != null && this.omitFooterAtBreak) { - if (tableFooter.layout(areaContainer).isIncomplete()) { - // this is a problem since we need to remove a row - // from the last table body and place it on the - // next page so that it can have a footer at - // the end of the table. - MessageHandler.errorln("WARNING: footer could not fit on page, moving last body row to next page"); - area.addChild(areaContainer); - area.increaseHeight(areaContainer.getHeight()); - area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); - if (this.omitHeaderAtBreak) { - // remove header, no longer needed - tableHeader = null; - } - tableFooter.removeLayout(areaContainer); - tableFooter.resetMarker(); - return new Status(Status.AREA_FULL_SOME); - } - } - - if (height != 0) - areaContainer.setHeight(height); - - setupColumnHeights(); - - areaContainer.end(); - area.addChild(areaContainer); - - /* should this be combined into above? */ - area.increaseHeight(areaContainer.getHeight()); - - area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); - - if (spaceAfter != 0) { - area.addDisplaySpace(spaceAfter); - } - - if (area instanceof BlockArea) { - area.start(); - } - - if (breakAfter == BreakAfter.PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK); - } - - if (breakAfter == BreakAfter.ODD_PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_ODD); - } - - if (breakAfter == BreakAfter.EVEN_PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_EVEN); - } - - return new Status(Status.OK); - } - - protected void setupColumnHeights() { - int numChildren = this.children.size(); - for (int i = 0; i < numChildren; i++) { - FONode fo = (FONode)children.elementAt(i); - if (fo instanceof TableColumn) { - ((TableColumn)fo).setHeight(areaContainer.getContentHeight()); - } - } - } - - public int getAreaHeight() { - return areaContainer.getHeight(); - } - - /** - * Return the content width of the boxes generated by this table FO. - */ - public int getContentWidth() { - if (areaContainer != null) - return areaContainer.getContentWidth(); // getAllocationWidth()?? - else - return 0; // not laid out yet - } - - // /** - // * Return the last TableRow in the header or null if no header or - // * no header in non-first areas. - // * @param bForInitialArea If true, return the header row for the - // * initial table area, else for a continuation area, taking into - // * account the omit-header-at-break property. - // */ - // TableRow getLastHeaderRow(boolean bForInitialArea) { - // // Check omit... - // if ((tableHeader != null) && - // (bForInitialArea || omitHeaderAtBreak == false)) { - // return tableHeader.children.lastElement(); - // } - // return null; - // } - - // /** - // * Return the first TableRow in the footer or null if no footer or - // * no footer in non-last areas. - // * @param bForFinalArea If true, return the footer row for the - // * final table area, else for a non-final area, taking into - // * account the omit-footer-at-break property. - // */ - // TableRow getLastFooterRow(boolean bForFinalArea) { - // if ((tableFooter != null) && - // (bForFinalArea || omitFooterAtBreak == false)) { - // return tableFooter.children.firstElement(); - // } - // return null; - // } - - - // /** - // * Return border information for the side (start/end) of the column - // * whose number is iColNumber (first column = 1). - // * ATTENTION: for now we assume columns are in order in the array! - // */ - // BorderInfo getColumnBorder(BorderInfo.Side side, int iColNumber) { - // TableColumn col = (TableColumn)columns.elementAt(iColNumber); - // return col.getBorderInfo(side); - // } -} diff --git a/src/org/apache/fop/fo/flow/TableAndCaption.java b/src/org/apache/fop/fo/flow/TableAndCaption.java deleted file mode 100644 index b9243aeea..000000000 --- a/src/org/apache/fop/fo/flow/TableAndCaption.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * -- $Id$ -- - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.fo.flow.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; - -/** - */ -public class TableAndCaption extends ToBeImplementedElement { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new TableAndCaption(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new TableAndCaption.Maker(); - } - - protected TableAndCaption(FObj parent, - PropertyList propertyList) throws FOPException { - super(parent, propertyList); - this.name = "fo:table-and-caption"; - } - - public Status layout(Area area) throws FOPException { - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Margin Properties-Block - MarginProps mProps = propMgr.getMarginProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("caption-side"); - // this.properties.get("id"); - // this.properties.get("keep-together"); - // this.properties.get("keep-with-next"); - // this.properties.get("keep-with-previous"); - - return super.layout(area); - } -} diff --git a/src/org/apache/fop/fo/flow/TableBody.java b/src/org/apache/fop/fo/flow/TableBody.java deleted file mode 100644 index 7ca06d172..000000000 --- a/src/org/apache/fop/fo/flow/TableBody.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.datatypes.*; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; - -// Java -import java.util.Vector; -import java.util.Enumeration; - -public class TableBody extends FObj { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new TableBody(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new TableBody.Maker(); - } - - int spaceBefore; - int spaceAfter; - ColorType backgroundColor; - String id; - - Vector columns; - RowSpanMgr rowSpanMgr; // manage information about spanning rows - - AreaContainer areaContainer; - - public TableBody(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:table-body"; - } - - public void setColumns(Vector columns) { - this.columns = columns; - } - - public void setYPosition(int value) { - areaContainer.setYPosition(value); - } - - public int getYPosition() { - return areaContainer.getCurrentYPosition(); - } - - public int getHeight() { - return areaContainer.getHeight() + spaceBefore + spaceAfter; - } - - public Status layout(Area area) throws FOPException { - if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); - } - - if (this.marker == START) { - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("id"); - - this.spaceBefore = - this.properties.get("space-before.optimum").getLength().mvalue(); - this.spaceAfter = - this.properties.get("space-after.optimum").getLength().mvalue(); - this.backgroundColor = - this.properties.get("background-color").getColorType(); - this.id = this.properties.get("id").getString(); - - area.getIDReferences().createID(id); - - if (area instanceof BlockArea) { - area.end(); - } - - if (rowSpanMgr == null) { - rowSpanMgr = new RowSpanMgr(columns.size()); - } - - // if (this.isInListBody) { - // startIndent += bodyIndent + distanceBetweenStarts; - // } - - this.marker = 0; - - } - - if ((spaceBefore != 0) && (this.marker == 0)) { - area.increaseHeight(spaceBefore); - } - - if (marker == 0) { - // configure id - area.getIDReferences().configureID(id, area); - } - - int spaceLeft = area.spaceLeft(); - - /* - * Note: the parent FO must be a Table. The parent Area is the Block - * type area created by the Table, which is also a reference area. - * The content "width" (IPD) of the TableBody is the same as that - * of the containing table area, and its relative position is 0,0. - * Strictly speaking (CR), this FO should generate no areas! - */ - this.areaContainer = - new AreaContainer(propMgr.getFontState(area.getFontInfo()), 0, - area.getContentHeight(), - area.getContentWidth(), // IPD - area.spaceLeft(), Position.RELATIVE); - areaContainer.foCreator = this; // G Seshadri - areaContainer.setPage(area.getPage()); - areaContainer.setBackgroundColor(backgroundColor); - areaContainer.setBorderAndPadding(propMgr.getBorderAndPadding()); - areaContainer.start(); - - areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); - areaContainer.setIDReferences(area.getIDReferences()); - - Vector keepWith = new Vector(); - int numChildren = this.children.size(); - TableRow lastRow = null; - boolean endKeepGroup = true; - for (int i = this.marker; i < numChildren; i++) { - Object child = children.elementAt(i); - if (!(child instanceof TableRow)) { - throw new FOPException("Currently only Table Rows are supported in table body, header and footer"); - } - TableRow row = (TableRow)child; - - row.setRowSpanMgr(rowSpanMgr); - row.setColumns(columns); - row.doSetup(areaContainer); - if (row.getKeepWithPrevious().getType() - != KeepValue.KEEP_WITH_AUTO && lastRow != null - && keepWith.indexOf(lastRow) - == -1) { - keepWith.addElement(lastRow); - } else { - if (endKeepGroup && keepWith.size() > 0) { - keepWith = new Vector(); - } - } - - Status status; - if ((status = row.layout(areaContainer)).isIncomplete()) { - // BUG!!! don't distinguish between break-before and after! - if (status.isPageBreak()) { - this.marker = i; - area.addChild(areaContainer); - // areaContainer.end(); - - area.increaseHeight(areaContainer.getHeight()); - area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); - if (i == numChildren - 1) { - this.marker = BREAK_AFTER; - if (spaceAfter != 0) { - area.increaseHeight(spaceAfter); - } - } - return status; - } - if (keepWith.size() - > 0) { // && status.getCode() == Status.AREA_FULL_NONE - // FIXME!!! Handle rows spans!!! - row.removeLayout(areaContainer); - for (Enumeration e = keepWith.elements(); - e.hasMoreElements(); ) { - TableRow tr = (TableRow)e.nextElement(); - tr.removeLayout(areaContainer); - i--; - } - if (i == 0) { - resetMarker(); - return new Status(Status.AREA_FULL_NONE); - } - } - this.marker = i; - if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) { - status = new Status(Status.AREA_FULL_SOME); - } - if (!((i == 0) && (areaContainer.getContentHeight() <= 0))) { - area.addChild(areaContainer); - // areaContainer.end(); - - area.increaseHeight(areaContainer.getHeight()); - area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); - } - return status; - } else if (status.getCode() == Status.KEEP_WITH_NEXT - || rowSpanMgr.hasUnfinishedSpans()) { - keepWith.addElement(row); - endKeepGroup = false; - } else { - endKeepGroup = true; - } - lastRow = row; - area.setMaxHeight(area.getMaxHeight() - spaceLeft - + this.areaContainer.getMaxHeight()); - spaceLeft = area.spaceLeft(); - } - area.addChild(areaContainer); - areaContainer.end(); - - area.increaseHeight(areaContainer.getHeight()); - - area.setAbsoluteHeight(areaContainer.getAbsoluteHeight()); - - if (spaceAfter != 0) { - area.increaseHeight(spaceAfter); - area.setMaxHeight(area.getMaxHeight() - spaceAfter); - } - - if (area instanceof BlockArea) { - area.start(); - } - - return new Status(Status.OK); - } - - public void removeLayout(Area area) { - if (areaContainer != null) { - area.removeChild(areaContainer); - } - if (spaceBefore != 0) { - area.increaseHeight(-spaceBefore); - } - if (spaceAfter != 0) { - area.increaseHeight(-spaceAfter); - } - this.resetMarker(); - this.removeID(area.getIDReferences()); - } - -} diff --git a/src/org/apache/fop/fo/flow/TableCaption.java b/src/org/apache/fop/fo/flow/TableCaption.java deleted file mode 100644 index 93712f309..000000000 --- a/src/org/apache/fop/fo/flow/TableCaption.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * -- $Id$ -- - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.fo.flow.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; - -/** - */ -public class TableCaption extends ToBeImplementedElement { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new TableCaption(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new TableCaption.Maker(); - } - - protected TableCaption(FObj parent, - PropertyList propertyList) throws FOPException { - super(parent, propertyList); - this.name = "fo:table-caption"; - } - - public Status layout(Area area) throws FOPException { - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("block-progression-dimension"); - // this.properties.get("height"); - // this.properties.get("id"); - // this.properties.get("inline-progression-dimension"); - // this.properties.get("keep-togethe"); - // this.properties.get("width"); - - return super.layout(area); - } -} diff --git a/src/org/apache/fop/fo/flow/TableCell.java b/src/org/apache/fop/fo/flow/TableCell.java deleted file mode 100644 index 24d5d12d4..000000000 --- a/src/org/apache/fop/fo/flow/TableCell.java +++ /dev/null @@ -1,462 +0,0 @@ -/* - * -- $Id$ -- - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.*; - -public class TableCell extends FObj { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new TableCell(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new TableCell.Maker(); - } - - // int spaceBefore; - // int spaceAfter; - ColorType backgroundColor; - - String id; - int numColumnsSpanned; - int numRowsSpanned; - int iColNumber = -1; // uninitialized - - /** - * Offset of content rectangle in inline-progression-direction, - * relative to table. - */ - protected int startOffset; - - /** - * Dimension of allocation rectangle in inline-progression-direction, - * determined by the width of the column(s) occupied by the cell - */ - protected int width; - - /** - * Offset of content rectangle, in block-progression-direction, - * relative to the row. - */ - protected int beforeOffset = 0; - - /** - * Offset of content rectangle, in inline-progression-direction, - * relative to the column start edge. - */ - protected int startAdjust = 0; - - /** - * Adjust to theoretical column width to obtain content width - * relative to the column start edge. - */ - protected int widthAdjust = 0; - - /* For collapsed border style */ - protected int borderHeight = 0; - - /** - * Minimum ontent height of cell. - */ - protected int minCellHeight = 0; - - protected int height = 0; - protected int top; // Ypos of cell ??? - protected int verticalAlign; - protected boolean bRelativeAlign = false; - - // boolean setup = false; - boolean bSepBorders = true; - - /** - * Border separation value in the block-progression dimension. - * Used in calculating cells height. - */ - int m_borderSeparation = 0; - - AreaContainer cellArea; - - public TableCell(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:table-cell"; - doSetup(); // init some basic property values - } - - // Set position relative to table (set by body?) - public void setStartOffset(int offset) { - startOffset = offset; - } - - // Initially same as the column width containg this cell or the - // sum of the spanned columns if numColumnsSpanned > 1 - public void setWidth(int width) { - this.width = width; - } - - public int getColumnNumber() { - return iColNumber; - } - - public int getNumColumnsSpanned() { - return numColumnsSpanned; - } - - public int getNumRowsSpanned() { - return numRowsSpanned; - } - - public void doSetup() // throws FOPException - { - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("border-after-precedence"); - // this.properties.get("border-before-precendence"); - // this.properties.get("border-end-precendence"); - // this.properties.get("border-start-precendence"); - // this.properties.get("block-progression-dimension"); - // this.properties.get("column-number"); - // this.properties.get("display-align"); - // this.properties.get("relative-align"); - // this.properties.get("empty-cells"); - // this.properties.get("ends-row"); - // this.properties.get("height"); - // this.properties.get("id"); - // this.properties.get("number-columns-spanned"); - // this.properties.get("number-rows-spanned"); - // this.properties.get("starts-row"); - // this.properties.get("width"); - - this.iColNumber = - properties.get("column-number").getNumber().intValue(); - if (iColNumber < 0) { - iColNumber = 0; - } - this.numColumnsSpanned = - this.properties.get("number-columns-spanned").getNumber().intValue(); - if (numColumnsSpanned < 1) { - numColumnsSpanned = 1; - } - this.numRowsSpanned = - this.properties.get("number-rows-spanned").getNumber().intValue(); - if (numRowsSpanned < 1) { - numRowsSpanned = 1; - } - - this.backgroundColor = - this.properties.get("background-color").getColorType(); - - this.id = this.properties.get("id").getString(); - - bSepBorders = (this.properties.get("border-collapse").getEnum() - == BorderCollapse.SEPARATE); - - calcBorders(propMgr.getBorderAndPadding()); - - // Vertical cell alignment - verticalAlign = this.properties.get("display-align").getEnum(); - if (verticalAlign == DisplayAlign.AUTO) { - // Depends on all cells starting in row - bRelativeAlign = true; - verticalAlign = this.properties.get("relative-align").getEnum(); - } else - bRelativeAlign = false; // Align on a per-cell basis - - this.minCellHeight = - this.properties.get("height").getLength().mvalue(); - } - - - public Status layout(Area area) throws FOPException { - int originalAbsoluteHeight = area.getAbsoluteHeight(); - if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); - } - - if (this.marker == START) { - // if (!setup) { - // doSetup(area); - // } - - // Calculate cell borders - // calcBorders(propMgr.getBorderAndPadding()); - - area.getIDReferences().createID(id); - - this.marker = 0; - } - - /* - * if ((spaceBefore != 0) && (this.marker ==0)) { - * area.increaseHeight(spaceBefore); - * } - */ - - if (marker == 0) { - // configure id - area.getIDReferences().configureID(id, area); - } - - // int spaceLeft = area.spaceLeft() - m_borderSeparation/2 + borderHeight/2 ; - int spaceLeft = area.spaceLeft() - m_borderSeparation; - // The Area position defines the content rectangle! Borders - // and padding are outside of this rectangle. - this.cellArea = - new AreaContainer(propMgr.getFontState(area.getFontInfo()), - startOffset + startAdjust, beforeOffset, - width - widthAdjust, spaceLeft, - Position.RELATIVE); - - cellArea.foCreator = this; // G Seshadri - cellArea.setPage(area.getPage()); - try { - cellArea.setBorderAndPadding((BorderAndPadding) - propMgr.getBorderAndPadding().clone()); - } catch (CloneNotSupportedException e) { - System.err.println("Can't clone BorderAndPadding: " + e) ; - cellArea.setBorderAndPadding(propMgr.getBorderAndPadding()); - } - cellArea.setBackgroundColor(this.backgroundColor); - cellArea.start(); - - cellArea.setAbsoluteHeight(area.getAbsoluteHeight()); // ??? - cellArea.setIDReferences(area.getIDReferences()); - // ******** CHECK THIS: we've changed startOffset (KL) - cellArea.setTableCellXOffset(startOffset); - - int numChildren = this.children.size(); - for (int i = this.marker; i < numChildren; i++) { - FObj fo = (FObj)children.elementAt(i); - fo.setIsInTableCell(); - fo.forceWidth(width); // ??? - - // Overflows may cause a row to be re-layedout, - // need to pass already processed content. - this.marker = i; - - Status status; - if ((status = fo.layout(cellArea)).isIncomplete()) { - // this.marker = i; - if ((i == 0) && (status.getCode() == Status.AREA_FULL_NONE)) { - return new Status(Status.AREA_FULL_NONE); - } else { - // hani Elabed 11/21/2000 - area.addChild(cellArea); - // area.setAbsoluteHeight(cellArea.getAbsoluteHeight()); - return new Status(Status.AREA_FULL_SOME); - } - } - - area.setMaxHeight(area.getMaxHeight() - spaceLeft - + this.cellArea.getMaxHeight()); - } - cellArea.end(); - area.addChild(cellArea); - - // Adjust for minimum cell content height - if (minCellHeight > cellArea.getContentHeight()) { - cellArea.setHeight(minCellHeight); - } - - // This is the allocation height of the cell (including borders - // and padding - // ALSO need to include offsets if using "separate borders" - height = cellArea.getHeight(); - top = cellArea.getCurrentYPosition(); // CHECK THIS!!! - - // reset absoluteHeight to beginning of row - // area.setHeight(cellArea.getHeight() + spaceBefore + spaceAfter); - // I don't think we should do this here (KL) !!! - // area.setHeight(cellArea.getHeight()); - // area.setAbsoluteHeight(originalAbsoluteHeight); - - return new Status(Status.OK); - } - - /** - * Return the allocation height of the cell area. - * Note: called by TableRow. - * We adjust the actual allocation height of the area by the value - * of border separation (for separate borders) or border height - * adjustment for collapse style (because current scheme makes cell - * overestimate the allocation height). - */ - public int getHeight() { - return cellArea.getHeight() + m_borderSeparation - borderHeight; - } - - /** - * Set the final size of cell content rectangles to the actual row height - * and to vertically align the actual content within the cell rectangle. - * @param h Height of this row in the grid which is based on - * the allocation height of all the cells in the row, including any - * border separation values. - */ - public void setRowHeight(int h) { - int delta = h - getHeight(); - // cellArea.increaseHeight(h + borderHeight/2 - cellArea.getHeight()); - if (bRelativeAlign) { - // Must get info for all cells starting in row! - // verticalAlign can be BEFORE or BASELINE - // For now just treat like "before" - cellArea.increaseHeight(delta); - } else if (delta > 0) { - BorderAndPadding cellBP = cellArea.getBorderAndPadding(); - switch (verticalAlign) { - case DisplayAlign.CENTER: - // Increase cell padding before and after and change - // "Y" position of content rectangle - cellArea.shiftYPosition(delta / 2); - cellBP.setPaddingLength(BorderAndPadding.TOP, - cellBP.getPaddingTop(false) - + delta / 2); - cellBP.setPaddingLength(BorderAndPadding.BOTTOM, - cellBP.getPaddingBottom(false) - + delta - delta / 2); - break; - case DisplayAlign.AFTER: - // Increase cell padding before and change - // "Y" position of content rectangle - cellBP.setPaddingLength(BorderAndPadding.TOP, - cellBP.getPaddingTop(false) + delta); - cellArea.shiftYPosition(delta); - break; - case DisplayAlign.BEFORE: - // cellArea.increaseHeight(delta); - cellBP.setPaddingLength(BorderAndPadding.BOTTOM, - cellBP.getPaddingBottom(false) - + delta); - - default: // OK - break; - } - } - } - - /** - * Calculate cell border and padding, including offset of content - * rectangle from the theoretical grid position. - */ - private void calcBorders(BorderAndPadding bp) { - if (this.bSepBorders) { - /* - * Easy case. - * Cell border is the property specified directly on cell. - * Offset content rect by half the border-separation value, - * in addition to the border and padding values. Note: - * border-separate should only be specified on the table object, - * but it inherits. - */ - int iSep = - properties.get("border-separation.inline-progression-direction").getLength().mvalue(); - this.startAdjust = iSep / 2 + bp.getBorderLeftWidth(false) - + bp.getPaddingLeft(false); - /* - * int contentOffset = iSep + bp.getBorderStartWidth(false) + - * bp.getPaddingStart(false); - */ - this.widthAdjust = startAdjust + iSep - iSep / 2 - + bp.getBorderRightWidth(false) - + bp.getPaddingRight(false); - // bp.getBorderEndWidth(false) + bp.getPaddingEnd(false); - // Offset of content rectangle in the block-progression direction - m_borderSeparation = - properties.get("border-separation.block-progression-direction").getLength().mvalue(); - this.beforeOffset = m_borderSeparation / 2 - + bp.getBorderTopWidth(false) - + bp.getPaddingTop(false); - // bp.getBorderBeforeWidth(false) + bp.getPaddingBefore(false); - - } else { - // System.err.println("Collapse borders"); - /* - * Hard case. - * Cell border is combination of other cell borders, or table - * border for edge cells. Also seems to border values specified - * on row and column FO in the table (if I read CR correclty.) - */ - - // Set up before and after borders, taking into account row - // and table border properties. - // ??? What about table-body, header,footer - - /* - * We can't calculate before and after because we aren't sure - * whether this row will be the first or last in its area, due - * to redoing break decisions (at least in the "new" architecture.) - * So in the general case, we will calculate two possible values: - * the first/last one and the "middle" one. - * Example: border-before - * 1. If the cell is in the first row in the first table body, it - * will combine with the last row of the header, or with the - * top (before) table border if there is no header. - * 2. Otherwise there are two cases: - * a. the row is first in its (non-first) Area. - * The border can combine with either: - * i. the last row of table-header and its cells, or - * ii. the table before border (no table-header or it is - * omitted on non-first Areas). - * b. the row isn't first in its Area. - * The border combines with the border of the previous - * row and the cells which end in that row. - */ - - /* - * if-first - * Calculate the effective border of the cell before-border, - * it's parent row before-border, the last header row after-border, - * the after border of the cell(s) which end in the last header - * row. - */ - /* - * if-not-first - * Calculate the effective border of the cell before-border, - * it's parent row before-border, the previous row after-border, - * the after border of the cell(s) which end in the previous - * row. - */ - - - /* ivan demakov */ - int borderStart = bp.getBorderLeftWidth(false); - int borderEnd = bp.getBorderRightWidth(false); - int borderBefore = bp.getBorderTopWidth(false); - int borderAfter = bp.getBorderBottomWidth(false); - - this.startAdjust = borderStart / 2 + bp.getPaddingLeft(false); - - this.widthAdjust = startAdjust + borderEnd / 2 - + bp.getPaddingRight(false); - this.beforeOffset = borderBefore / 2 + bp.getPaddingTop(false); - // Half border height to fix overestimate of area size! - this.borderHeight = (borderBefore + borderAfter) / 2; - } - } - - -} diff --git a/src/org/apache/fop/fo/flow/TableColumn.java b/src/org/apache/fop/fo/flow/TableColumn.java deleted file mode 100644 index 2afe6cafc..000000000 --- a/src/org/apache/fop/fo/flow/TableColumn.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.*; - -public class TableColumn extends FObj { - - ColorType backgroundColor; - - int columnWidth; - int columnOffset; - int numColumnsRepeated; - - boolean setup = false; - - AreaContainer areaContainer; - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new TableColumn(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new TableColumn.Maker(); - } - - public TableColumn(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:table-column"; - } - - public int getColumnWidth() { - return columnWidth; - } - - public int getColumnNumber() { - return 0; // not implemented yet - } - - public int getNumColumnsRepeated() { - return numColumnsRepeated; - } - - public void doSetup(Area area) throws FOPException { - - // Common Border, Padding, and Background Properties - // only background apply, border apply if border-collapse - // is collapse. - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // this.properties.get("column-number"); - // this.properties.get("column-width"); - // this.properties.get("number-columns-repeated"); - // this.properties.get("number-columns-spanned"); - // this.properties.get("visibility"); - - - this.numColumnsRepeated = - this.properties.get("number-columns-repeated").getNumber().intValue(); - - this.backgroundColor = - this.properties.get("background-color").getColorType(); - - this.columnWidth = - this.properties.get("column-width").getLength().mvalue(); - - // initialize id - String id = this.properties.get("id").getString(); - area.getIDReferences().initializeID(id, area); - - setup = true; - } - - public Status layout(Area area) throws FOPException { - if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); - } - - if (this.marker == START) { - if (!setup) { - doSetup(area); - } - } - - // KL: don't take table borders into account! - this.areaContainer = - new AreaContainer(propMgr.getFontState(area.getFontInfo()), - columnOffset /* - area.getBorderLeftWidth() */, - /* -area.getBorderTopWidth() */ - 0, columnWidth, area.getContentHeight(), Position.RELATIVE); - // area.getHeight(), Position.RELATIVE); - areaContainer.foCreator = this; // G Seshadri - areaContainer.setPage(area.getPage()); - areaContainer.setBorderAndPadding(propMgr.getBorderAndPadding()); - areaContainer.setBackgroundColor(this.backgroundColor); - areaContainer.setHeight(area.getHeight()); - area.addChild(areaContainer); - - return new Status(Status.OK); - } - - public void setColumnOffset(int columnOffset) { - this.columnOffset = columnOffset; - } - - public void setHeight(int height) { - areaContainer.setMaxHeight(height); - areaContainer.setHeight(height); - } - -} diff --git a/src/org/apache/fop/fo/flow/TableFooter.java b/src/org/apache/fop/fo/flow/TableFooter.java deleted file mode 100644 index 0a6ebe02d..000000000 --- a/src/org/apache/fop/fo/flow/TableFooter.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.datatypes.*; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; - -// Java -import java.util.Vector; -import java.util.Enumeration; - -public class TableFooter extends TableBody { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new TableFooter(parent, propertyList); - } - - } - - public int getYPosition() { - return areaContainer.getCurrentYPosition() - spaceBefore; - } - - public void setYPosition(int value) { - areaContainer.setYPosition(value + 2 * spaceBefore); - } - - public static FObj.Maker maker() { - return new TableFooter.Maker(); - } - - public TableFooter(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:table-footer"; - } - -} diff --git a/src/org/apache/fop/fo/flow/TableHeader.java b/src/org/apache/fop/fo/flow/TableHeader.java deleted file mode 100644 index 81fd7a69b..000000000 --- a/src/org/apache/fop/fo/flow/TableHeader.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.fo.properties.*; -import org.apache.fop.datatypes.*; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; - -// Java -import java.util.Vector; -import java.util.Enumeration; - -public class TableHeader extends TableBody { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new TableHeader(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new TableHeader.Maker(); - } - - public TableHeader(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:table-header"; - } - -} diff --git a/src/org/apache/fop/fo/flow/TableRow.java b/src/org/apache/fop/fo/flow/TableRow.java deleted file mode 100644 index d2d879c97..000000000 --- a/src/org/apache/fop/fo/flow/TableRow.java +++ /dev/null @@ -1,545 +0,0 @@ -/* - * -- $Id$ -- - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.messaging.MessageHandler; -import org.apache.fop.fo.properties.*; -import org.apache.fop.datatypes.*; -import org.apache.fop.layout.*; -import org.apache.fop.apps.FOPException; - -// Java -import java.util.Vector; -import java.util.Enumeration; - -public class TableRow extends FObj { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new TableRow(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new TableRow.Maker(); - } - - boolean setup = false; - - int breakAfter; - ColorType backgroundColor; - String id; - - KeepValue keepWithNext; - KeepValue keepWithPrevious; - KeepValue keepTogether; - - int widthOfCellsSoFar = 0; - int largestCellHeight = 0; - int minHeight = 0; // force row height - Vector columns; - - AreaContainer areaContainer; - - boolean areaAdded = false; - - private RowSpanMgr rowSpanMgr = null; - private CellArray cellArray = null; - - private static class CellArray { - public static final byte EMPTY = 0; - public static final byte CELLSTART = 1; - public static final byte CELLSPAN = 2; - - private TableCell[] cells; - private byte[] states; - - public CellArray(RowSpanMgr rsi, int numColumns) { - // Initialize the cell array by marking any cell positions - // occupied by spans from previous rows - cells = new TableCell[numColumns]; - states = new byte[numColumns]; - for (int i = 0; i < numColumns; i++) { - if (rsi.isSpanned(i + 1)) { - cells[i] = rsi.getSpanningCell(i + 1); - states[i] = CELLSPAN; - } else - states[i] = EMPTY; - } - } - - /** - * Return column which doesn't already contain a span or a cell - * If past the end or no free cells after colNum, return -1 - * Otherwise return value >= input value. - */ - int getNextFreeCell(int colNum) { - for (int i = colNum - 1; i < states.length; i++) { - if (states[i] == EMPTY) - return i + 1; - } - return -1; - } - - - /** - * Return type of cell in colNum (1 based) - */ - int getCellType(int colNum) { - if (colNum > 0 && colNum <= cells.length) { - return states[colNum - 1]; - } else - return -1; // probably should throw exception - } - - /** - * Return cell in colNum (1 based) - */ - TableCell getCell(int colNum) { - if (colNum > 0 && colNum <= cells.length) { - return cells[colNum - 1]; - } else - return null; // probably should throw exception - } - - /** - * Store cell starting at cellColNum (1 based) and spanning numCols - * If any of the columns is already occupied, return false, else true - */ - boolean storeCell(TableCell cell, int colNum, int numCols) { - boolean rslt = true; - int index = colNum - 1; - for (int count = 0; index < cells.length && count < numCols; - count++, index++) { - if (cells[index] == null) { - cells[index] = cell; - states[index] = (count == 0) ? CELLSTART : CELLSPAN; - } else { - rslt = false; - // print a message but continue!!! - } - } - return rslt; - } - - // private class EnumCells implements Enumeration { - // private int iNextIndex=0; - // private Object nextCell = null; - // EnumCells() { - // findNextCell(); - // } - - // private void findNextCell() { - // for (; iNextIndex < cells.length; iNextIndex++) { - // if (states[iNextIndex] == CELLSTART) { - // nextCell = cells[iNextIndex]; - // return; - // } - // } - // nextCell = null; - // } - - // public boolean hasMoreElements() { - // return (nextCell != null); - // } - - // public Object nextElement() { - // if (nextCell != null) { - // Object cell = nextCell; - // findNextCell(); - // return cell; - // } - // else throw new java.util.NoSuchElementException("No more cells"); - // } - // } - - // /** - // * Return an enumeration over all cells in this row - // * Return each element in cells whose state is CELLSTART or EMPTY? - // * Skip spanning elements. - // */ - // Enumeration getCells() { - // return new EnumCells(); - // } - } - - - public TableRow(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "fo:table-row"; - } - - public void setColumns(Vector columns) { - this.columns = columns; - } - - public KeepValue getKeepWithPrevious() { - return keepWithPrevious; - } - - public void doSetup(Area area) throws FOPException { - - // Common Accessibility Properties - AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); - - // this.properties.get("block-progression-dimension"); - - // Common Aural Properties - AuralProps mAurProps = propMgr.getAuralProps(); - - // Common Border, Padding, and Background Properties - // only background apply, border apply if border-collapse - // is collapse. - BorderAndPadding bap = propMgr.getBorderAndPadding(); - BackgroundProps bProps = propMgr.getBackgroundProps(); - - // Common Relative Position Properties - RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); - - // this.properties.get("break-before"); - // this.properties.get("break-after"); - // this.properties.get("id"); - // this.properties.get("height"); - // this.properties.get("keep-together"); - // this.properties.get("keep-with-next"); - // this.properties.get("keep-with-previous"); - - - this.breakAfter = this.properties.get("break-after").getEnum(); - this.backgroundColor = - this.properties.get("background-color").getColorType(); - - this.keepTogether = getKeepValue("keep-together.within-column"); - this.keepWithNext = getKeepValue("keep-with-next.within-column"); - this.keepWithPrevious = - getKeepValue("keep-with-previous.within-column"); - - this.id = this.properties.get("id").getString(); - this.minHeight = this.properties.get("height").getLength().mvalue(); - setup = true; - } - - private KeepValue getKeepValue(String sPropName) { - Property p = this.properties.get(sPropName); - Number n = p.getNumber(); - if (n != null) - return new KeepValue(KeepValue.KEEP_WITH_VALUE, n.intValue()); - switch (p.getEnum()) { - case Constants.ALWAYS: - return new KeepValue(KeepValue.KEEP_WITH_ALWAYS, 0); - // break; - case Constants.AUTO: - default: - return new KeepValue(KeepValue.KEEP_WITH_AUTO, 0); - // break; - } - } - - public Status layout(Area area) throws FOPException { - boolean configID = false; - - if (this.marker == BREAK_AFTER) { - return new Status(Status.OK); - } - - // Layout the first area for this FO - if (this.marker == START) { - if (!setup) - doSetup(area); - - // Only do this once. If the row is "thrown" and we start - // layout over again, we can skip this. - if (cellArray == null) { - initCellArray(); - // check to make sure this row hasn't been partially - // laid out yet (with an id created already) - area.getIDReferences().createID(id); - configID = true; - } - - this.marker = 0; - int breakStatus = propMgr.checkBreakBefore(area); - if (breakStatus != Status.OK) - return new Status(breakStatus); - } - - // if (marker == 0 && configID) { - if (marker == 0) { // KDL: need to do this if thrown or if split? - // configure id - area.getIDReferences().configureID(id, area); - } - - int spaceLeft = area.spaceLeft(); - - this.areaContainer = - new AreaContainer(propMgr.getFontState(area.getFontInfo()), 0, 0, - area.getContentWidth(), spaceLeft, - Position.RELATIVE); - areaContainer.foCreator = this; // G Seshadri - areaContainer.setPage(area.getPage()); - - areaContainer.setBackgroundColor(backgroundColor); - areaContainer.start(); - - areaContainer.setAbsoluteHeight(area.getAbsoluteHeight()); - areaContainer.setIDReferences(area.getIDReferences()); - - largestCellHeight = minHeight; - - // Flag indicaing whether any cell didn't fit in available space - boolean someCellDidNotLayoutCompletely = false; - - /* - * If it takes multiple calls to completely layout the row, - * we need to process all of the children (cells) - * not just those from the marker so that the borders - * will be drawn properly. - */ - int offset = 0; // Offset of each cell from table start edge - int iColIndex = 0; // 1-based column index - Enumeration eCols = columns.elements(); - /* - * Ideas: set offset on each column when they are initialized - * no need to calculate for each row. - * Pass column object to cell to get offset and width and border - * info if borders are "collapsed". - */ - - while (eCols.hasMoreElements()) { - TableCell cell; - ++iColIndex; - TableColumn tcol = (TableColumn)eCols.nextElement(); - int colWidth = tcol.getColumnWidth(); - if (cellArray.getCellType(iColIndex) == CellArray.CELLSTART) { - cell = cellArray.getCell(iColIndex); - } else { - /* - * If this cell is spanned from a previous row, - * and this is the last row, get the remaining height - * and use it to increase maxCellHeight if necessary - */ - if (rowSpanMgr.isInLastRow(iColIndex)) { - int h = rowSpanMgr.getRemainingHeight(iColIndex); - if (h > largestCellHeight) - largestCellHeight = h; - } - offset += colWidth; - continue; - } - // cell.setTableColumn(tcol); - cell.setStartOffset(offset); - offset += colWidth; - - - int rowSpan = cell.getNumRowsSpanned(); - Status status; - if ((status = cell.layout(areaContainer)).isIncomplete()) { - if ((keepTogether.getType() == KeepValue.KEEP_WITH_ALWAYS) - || (status.getCode() == Status.AREA_FULL_NONE) - || rowSpan > 1) { - // We will put this row into the next column/page - // Note: the only time this shouldn't be honored is - // if this row is at the top of the column area. - // Remove spanning cells from RowSpanMgr? - this.resetMarker(); - this.removeID(area.getIDReferences()); - return new Status(Status.AREA_FULL_NONE); - } else if (status.getCode() == Status.AREA_FULL_SOME) { - /* - * Row is not keep-together, cell isn't spanning - * and part of it fits. We can break the cell and - * the row. - */ - someCellDidNotLayoutCompletely = true; - } - } // else { - // layout was complete for a particular cell - int h = cell.getHeight(); // allocation height of cell - if (rowSpan > 1) { // pass cell fo or area??? - rowSpanMgr.addRowSpan(cell, iColIndex, - cell.getNumColumnsSpanned(), h, - rowSpan); - } else if (h > largestCellHeight) { - largestCellHeight = h; - } - // } - } // end of loop over all columns/cells - - // This is in case a float was composed in the cells - area.setMaxHeight(area.getMaxHeight() - spaceLeft - + this.areaContainer.getMaxHeight()); - - // Only do this for "STARTCELL", ending spans are handled separately - // What about empty cells? Yes, we should set their height too! - for (int iCol = 1; iCol <= columns.size(); iCol++) { - if (cellArray.getCellType(iCol) == CellArray.CELLSTART - && rowSpanMgr.isSpanned(iCol) == false) { - cellArray.getCell(iCol).setRowHeight(largestCellHeight); - } - } - - // Adjust spanning row information - // ??? what if some cells are broken??? - rowSpanMgr.finishRow(largestCellHeight); - - area.addChild(areaContainer); - areaContainer.setHeight(largestCellHeight); - areaAdded = true; - areaContainer.end(); - - /* - * The method addDisplaySpace increases both the content - * height of the parent area (table body, head or footer) and - * also its "absolute height". So we don't need to do this - * explicitly. - * - * Note: it doesn't look from the CR as though we should take - * into account borders and padding on rows, only background. - * The exception is perhaps if the borders are "collapsed", but - * they should still be rendered only on cells and not on the - * rows themselves. (Karen Lease - 01may2001) - */ - area.addDisplaySpace(largestCellHeight - + areaContainer.getPaddingTop() - + areaContainer.getBorderTopWidth() - + areaContainer.getPaddingBottom() - + areaContainer.getBorderBottomWidth()); - - - // replaced by Hani Elabed 11/27/2000 - // return new Status(Status.OK); - - if (someCellDidNotLayoutCompletely) { - return new Status(Status.AREA_FULL_SOME); - } else { - if (rowSpanMgr.hasUnfinishedSpans()) { - // Ignore break after if row span! - return new Status(Status.KEEP_WITH_NEXT); - } - if (breakAfter == BreakAfter.PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK); - } - - if (breakAfter == BreakAfter.ODD_PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_ODD); - } - - if (breakAfter == BreakAfter.EVEN_PAGE) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_PAGE_BREAK_EVEN); - } - - if (breakAfter == BreakAfter.COLUMN) { - this.marker = BREAK_AFTER; - return new Status(Status.FORCE_COLUMN_BREAK); - } - if (keepWithNext.getType() != KeepValue.KEEP_WITH_AUTO) { - return new Status(Status.KEEP_WITH_NEXT); - } - return new Status(Status.OK); - } - - } - - public int getAreaHeight() { - return areaContainer.getHeight(); - } - - public void removeLayout(Area area) { - if (areaAdded) - area.removeChild(areaContainer); - areaAdded = false; - this.resetMarker(); - this.removeID(area.getIDReferences()); - } - - public void resetMarker() { - super.resetMarker(); - // Just reset all the states to not laid out and fix up row spans - } - - /** - * Called by parent FO to initialize information about - * cells started in previous rows which span into this row. - * The layout operation modifies rowSpanMgr - */ - public void setRowSpanMgr(RowSpanMgr rowSpanMgr) { - this.rowSpanMgr = rowSpanMgr; - } - - /** - * Before starting layout for the first time, initialize information - * about spanning rows, empty cells and spanning columns. - */ - private void initCellArray() { - cellArray = new CellArray(rowSpanMgr, columns.size()); - int colNum = 1; - Enumeration eCells = children.elements(); - while (eCells.hasMoreElements()) { - colNum = cellArray.getNextFreeCell(colNum); - // If off the end, the rest of the cells had better be - // explicitly positioned!!! (returns -1) - - TableCell cell = (TableCell)eCells.nextElement(); - int numCols = cell.getNumColumnsSpanned(); - int numRows = cell.getNumRowsSpanned(); - int cellColNum = cell.getColumnNumber(); - - if (cellColNum == 0) { - // Not explicitly specified, so put in next available colummn - // cell.setColumnNumber(colNum); - // If cellColNum "off the end", this cell is in limbo! - if (colNum < 1) { - // ERROR!!! - continue; - } else - cellColNum = colNum; - } else if (cellColNum > columns.size()) { - // Explicit specification out of range! - // Skip it and print an ERROR MESSAGE - continue; - } - // see if it fits and doesn't overwrite anything - if (cellColNum + numCols - 1 > columns.size()) { - // MESSAGE: TOO MANY COLUMNS SPANNED! - numCols = columns.size() - cellColNum + 1; - } - // Check for overwriting other cells (returns false) - if (cellArray.storeCell(cell, cellColNum, numCols) == false) { - // Print out some kind of warning message. - } - if (cellColNum > colNum) { - // Cells are initialized as empty already - colNum = cellColNum; - } else if (cellColNum < colNum) { - // MESSAGE ? cells out of order? - colNum = cellColNum; // CR "to the letter"! - } - int cellWidth = getCellWidth(cellColNum, numCols); - cell.setWidth(cellWidth); - colNum += numCols; // next cell in this column - } - } - - // ATTENTION if startCol + numCols > number of columns in table! - private int getCellWidth(int startCol, int numCols) { - int width = 0; - for (int count = 0; count < numCols; count++) { - width += ((TableColumn)columns.elementAt(startCol + count - - 1)).getColumnWidth(); - } - return width; - } - -} diff --git a/src/org/apache/fop/fo/flow/Wrapper.java b/src/org/apache/fop/fo/flow/Wrapper.java deleted file mode 100644 index 9e93439fe..000000000 --- a/src/org/apache/fop/fo/flow/Wrapper.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.fo.flow; - -// FOP -import org.apache.fop.fo.*; -import org.apache.fop.apps.FOPException; -import org.apache.fop.fo.properties.*; -import org.apache.fop.layout.*; - -/** - * Implementation for fo:wrapper formatting object. - * The wrapper object serves as - * a property holder for it's children objects. - * - * Content: (#PCDATA|%inline;|%block;)* - * Properties: id - */ -public class Wrapper extends FObjMixed { - - public static class Maker extends FObj.Maker { - public FObj make(FObj parent, - PropertyList propertyList) throws FOPException { - return new Wrapper(parent, propertyList); - } - - } - - public static FObj.Maker maker() { - return new Wrapper.Maker(); - } - - public Wrapper(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - // check that this occurs inside an fo:flow - } - - protected void addCharacters(char data[], int start, int length) { - FOText ft = new FOText(data, start, length, this); - children.addElement(ft); - } - -} -- 2.39.5