private Translator resource;
public AWTStarter(CommandLineOptions commandLineOptions)
- throws FOPException {
+ throws FOPException {
super(commandLineOptions);
init();
}
+ language);
UserMessage.setTranslator(getResourceBundle(TRANSLATION_PATH
- + "messages."
- + language));
+ + "messages."
+ + language));
resource.setMissingEmphasized(false);
renderer = new AWTRenderer(resource);
}
protected PreviewDialog createPreviewDialog(AWTRenderer renderer,
- Translator res) {
+ Translator res) {
PreviewDialog frame = new PreviewDialog(renderer, res);
frame.validate();
boolean errorDump;
public CommandLineStarter(CommandLineOptions commandLineOptions)
- throws FOPException {
+ throws FOPException {
this.commandLineOptions = commandLineOptions;
options.setCommandLineOptions(commandLineOptions);
errorDump = Configuration.getBooleanValue("debugMode").booleanValue();
try {
parserClassName = System.getProperty("org.xml.sax.parser");
} catch (SecurityException se) {}
+
if (parserClassName == null) {
parserClassName = "org.apache.xerces.parsers.SAXParser";
}
try {
addElementMapping(str);
} catch (IllegalArgumentException e) {}
+
}
}
}
* @see #setRenderer(int)
*/
public void setRenderer(String rendererClassName)
- throws IllegalArgumentException {
+ throws IllegalArgumentException {
try {
_renderer =
(Renderer)Class.forName(rendererClassName).newInstance();
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Could not find "
+ rendererClassName);
- } catch (InstantiationException e) {
+ }
+ catch (InstantiationException e) {
throw new IllegalArgumentException("Could not instantiate "
+ rendererClassName);
- } catch (IllegalAccessException e) {
+ }
+ catch (IllegalAccessException e) {
throw new IllegalArgumentException("Could not access "
+ rendererClassName);
- } catch (ClassCastException e) {
+ }
+ catch (ClassCastException e) {
throw new IllegalArgumentException(rendererClassName
+ " is not a renderer");
}
* add the element mapping with the given class name
*/
public void addElementMapping(String mappingClassName)
- throws IllegalArgumentException {
+ throws IllegalArgumentException {
try {
ElementMapping mapping =
(ElementMapping)Class.forName(mappingClassName).newInstance();
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Could not find "
+ mappingClassName);
- } catch (InstantiationException e) {
+ }
+ catch (InstantiationException e) {
throw new IllegalArgumentException("Could not instantiate "
+ mappingClassName);
- } catch (IllegalAccessException e) {
+ }
+ catch (IllegalAccessException e) {
throw new IllegalArgumentException("Could not access "
+ mappingClassName);
- } catch (ClassCastException e) {
+ }
+ catch (ClassCastException e) {
throw new IllegalArgumentException(mappingClassName
+ " is not an ElementMapping");
}
* SAX InputSource
*/
public synchronized void render(XMLReader parser, InputSource source)
- throws FOPException {
+ throws FOPException {
StreamRenderer streamRenderer = new StreamRenderer(_stream, _renderer);
_treeBuilder.setStreamRenderer(streamRenderer);
parser.setContentHandler(_treeBuilder);
} else {
throw new FOPException(e);
}
- } catch (IOException e) {
+ }
+ catch (IOException e) {
throw new FOPException(e);
}
}
* Build the formatting object tree using the given DOM Document
*/
public synchronized void render(Document document)
- throws FOPException {
+ throws FOPException {
StreamRenderer streamRenderer = new StreamRenderer(_stream, _renderer);
_treeBuilder.setStreamRenderer(streamRenderer);
-
+
try {
DocumentInputSource source = new DocumentInputSource(document);
DocumentReader reader = new DocumentReader();
reader.parse(source);
} catch (SAXException e) {
throw new FOPException(e);
- } catch (IOException e) {
+ }
+ catch (IOException e) {
throw new FOPException(e);
}
this._bufferManager.addBufferFile(bufferFile);
}
- /**
+ /**
* Runs the formatting and renderering process using the previously set
* inputsource and outputstream
*/
if (_renderer == null) {
setRenderer(RENDER_PDF);
}
-
+
if (_source == null) {
throw new FOPException("InputSource is not set.");
}
-
+
if (_reader == null) {
if (!(_source instanceof DocumentInputSource)) {
_reader = ConfigurationReader.createParser();
}
}
-
+
if (_source instanceof DocumentInputSource) {
render(((DocumentInputSource)_source).getDocument());
} else {
if (idx != -1)
line = line.substring(0, idx);
- // Trim whitespace.
+ // Trim whitespace.
line = line.trim();
// If nothing left then loop around...
} catch (Exception ex) {
// Just try the next line
}
+
line = br.readLine();
}
} catch (Exception ex) {
// Just try the next file...
}
+
}
return v.elements();
}
PrinterJob pj = PrinterJob.getPrinterJob();
if(System.getProperty("dialog") != null)
- if(!pj.printDialog())
- throw new FOPException("Printing cancelled by operator");
-
+ 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());
}
System.exit(0);
- }
- int getIntProperty(String name, int def) {
- String propValue = System.getProperty(name);
- if(propValue != null) {
+ }
+ int getIntProperty(String name, int def) {
+ String propValue = System.getProperty(name);
+ if(propValue != null) {
try {
- return Integer.parseInt(propValue);
+ return Integer.parseInt(propValue);
} catch (Exception e) {
- return def;
+ return def;
}
- } else {
+ } else {
return def;
}
}
private int mode = EVEN_AND_ALL;
private int copies = 1;
private PrinterJob printerJob;
-
+
PrintRenderer(PrinterJob printerJob) {
super(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();
-
+ 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());
+ printerJob.print();
+ } catch (PrinterException e) {
+ e.printStackTrace();
+ throw new IOException(
+ "Unable to print: " + e.getClass().getName() +
+ ": " + e.getMessage());
}
}
tree.getPages().addAll(copie);
}
- }
- */
+ }
+ */
} // class PrintRenderer
} // class PrintCommandLine
PageSequences up until all the IDs required by them
are satisfied, at which time it will render the
pages.<P>
-
+
StreamRenderer is created by Driver and called from
FOTreeBuilder when a PageSequence is created,
and AreaTree when a Page is formatted.<P>
*/
-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. <B>Note</B> 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.
+public class StreamRenderer extends Object {
+ private static final boolean MEM_PROFILE_WITH_GC = false;
+
+ /**
+ Somewhere to get our stats from.
*/
- try {
- processQueue(true);
- renderer.stopRenderer(outputStream);
- }
- catch (FOPException e)
- {
- throw new SAXException(e);
- }
- catch (IOException e)
- {
- throw new SAXException(e);
- }
+ 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. <B>Note</B> 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;
- if (MEM_PROFILE_WITH_GC)
- System.gc(); // This takes time but gives better results
+ /**
+ The FontInfo for this renderer.
+ */
+ private FontInfo fontInfo = new FontInfo();
- long memoryNow = runtime.totalMemory() - runtime.freeMemory();
- long memoryUsed = (memoryNow - initialMemory) / 1024L;
+ /**
+ The list of pages waiting to be renderered.
+ */
+ private Vector renderQueue = new Vector();
- MessageHandler.logln("Initial heap size: " + (initialMemory/1024L) + "Kb");
- MessageHandler.logln("Current heap size: " + (memoryNow/1024L) + "Kb");
- MessageHandler.logln("Total memory used: " + memoryUsed + "Kb");
+ /**
+ 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();
- if (!MEM_PROFILE_WITH_GC)
- {
- MessageHandler.logln(" Memory use is indicative; no GC was performed");
- MessageHandler.logln(" These figures should not be used comparatively");
+ public StreamRenderer(OutputStream outputStream, Renderer renderer) {
+ this.outputStream = outputStream;
+ this.renderer = renderer;
}
- 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);
+ public IDReferences getIDReferences() {
+ return idReferences;
}
- catch (FOPException e)
- {
- throw new SAXException(e);
+
+ 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 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);
+
+ 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");
}
- }
-
- /**
- 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.<P>
- */
- class RenderQueueEntry extends Object
- {
- /*
- The Page that has outstanding ID references.
- */
- private Page page;
- /*
- A list of ID references (names).
+ /**
+ 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.
*/
- private Vector unresolvedIdReferences = new Vector();
+ 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 RenderQueueEntry(Page page)
- {
- this.page = page;
+ 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++;
+ }
- Enumeration e = idReferences.getInvalidElements();
- while (e.hasMoreElements())
- unresolvedIdReferences.addElement(e.nextElement());
+ 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);
}
- public Page getPage()
- {
- return page;
+ /**
+ 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);
+ }
}
/**
- See if the outstanding references are resolved
- in the current copy of IDReferences.
+ 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.<P>
*/
- 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;
+ 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;
+ }
}
- }
}
* ex. 23 0 R
*/
public void setInternalGoToPageReference(String id,
- String pageReference) {
+ String pageReference) {
IDNode node = (IDNode)idReferences.get(id);
if (node != null) {
node.setInternalLinkGoToPageReference(pageReference);
node.setPosition(x, y);
}
- public Enumeration getInvalidElements()
- {
- return idValidation.keys();
+ public Enumeration getInvalidElements() {
+ return idValidation.keys();
}
}
// still to do
}
+
protected void addChild(FONode child) {
children.addElement(child);
}
for (int i = s; i < e; i++)
ca[i - s] = chars[i];
this.length = e - s;
-
+
/* ML - remove refs to BufferManager
this.bufferManager = parent.bufferManager;
if (this.bufferManager != null) {
bufferManager.writeBuffer((Object)this, ca);
- } else {
+ } else {
System.out.println("abnormal exit");
System.exit(0);
- }
+ }
*/
}
public boolean willCreateArea() {
// ML - remove refs to BufferManager
//char ca[] = this.bufferManager.readBuffer((Object)this);
-
+
this.whiteSpaceCollapse =
this.parent.properties.get("white-space-collapse").getEnum();
if (this.whiteSpaceCollapse == WhiteSpaceCollapse.FALSE
isLowerCase = (java.lang.Character.isLetter(c)
&& java.lang.Character.isLowerCase(c));
while (isLowerCase
- == (java.lang.Character.isLetter(c)
- && java.lang.Character.isLowerCase(c))) {
+ == (java.lang.Character.isLetter(c)
+ && java.lang.Character.isLowerCase(c))) {
if (isLowerCase) {
data[i] = java.lang.Character.toUpperCase(c);
}
* The class that handles formatting and rendering to a stream
* (mark-fop@inomial.com)
*/
- private StreamRenderer streamRenderer;
-
- public FOTreeBuilder()
- {
- }
-
- public void setStreamRenderer(StreamRenderer streamRenderer)
- {
- this.streamRenderer = streamRenderer;
- }
-
+ private StreamRenderer streamRenderer;
+
+ public FOTreeBuilder() {}
+
+
+ public void setStreamRenderer(StreamRenderer streamRenderer) {
+ this.streamRenderer = streamRenderer;
+ }
+
/**
* add a mapping from element name to maker.
*
* SAX Handler for the end of an element
*/
public void endElement(String uri, String localName, String rawName)
- throws SAXException
- {
+ throws SAXException {
currentFObj.end();
-
+
//
// mark-fop@inomial.com - tell the stream renderer to render
// this page-sequence
//
if(currentFObj instanceof PageSequence)
- streamRenderer.render((PageSequence) currentFObj);
-
- currentFObj = (FObj)currentFObj.getParent();
+ streamRenderer.render((PageSequence) currentFObj);
+
+ currentFObj = (FObj)currentFObj.getParent();
}
/**
* SAX Handler for the start of the document
*/
public void startDocument()
- throws SAXException
- {
+ throws SAXException {
rootFObj = null; // allows FOTreeBuilder to be reused
MessageHandler.logln("building formatting object tree");
streamRenderer.startRenderer();
}
public void endDocument()
- throws SAXException
- {
- MessageHandler.logln("Parsing of document complete, stopping renderer");
- streamRenderer.stopRenderer();
+ throws SAXException {
+ MessageHandler.logln("Parsing of document complete, stopping renderer");
+ streamRenderer.stopRenderer();
}
-
+
/**
* SAX Handler for the start of an element
*/
fobjMaker = new FObjMixed.Maker(); // fall back
}
+
try {
PropertyList list = null;
if (currentListBuilder != null) {
+ " be root, not "
+ fobj.getName()));
}
- } else if(!(fobj instanceof org.apache.fop.fo.pagination.PageSequence)){
+ } else if(!(fobj instanceof org.apache.fop.fo.pagination.PageSequence)) {
currentFObj.addChild(fobj);
}
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.
- */
-
+/*
+ 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 {
int areaHeight = 0;
int contentWidth = 0;
-
+
String id;
int span;
this.areasGenerated++;
if (this.areasGenerated == 1)
blockArea.isFirst(true);
- // for normal areas this should be the only pair
+ // for normal areas this should be the only pair
blockArea.addLineagePair(this, this.areasGenerated);
// markers
return status;
} else // i == 0 nothing was laid out..
- {
+ {
anythingLaidOut = false;
return status;
}
// 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 (keepWithNext != 0) {
- blockArea = null; // Faster GC - BlockArea is big
+ blockArea = null; // Faster GC - BlockArea is big
return new Status(Status.KEEP_WITH_NEXT);
}
/**
* Return the content width of the boxes generated by this FO.
*/
- public int getContentWidth() {
+ public int getContentWidth() {
return contentWidth; // getAllocationWidth()??
}
+
public int getSpan() {
return this.span;
}
if (parent.getName().equals("fo:root")) {
this.root = (Root)parent;
// this.root.addPageSequence(this);
- } else {
+ }
+ else {
throw new FOPException("page-sequence must be child of root, not "
+ parent.getName());
}
// this.properties.get("id");
}
+
public void addFlow(Flow flow) throws FOPException {
if (_flowMap.containsKey(flow.getFlowName())) {
throw new FOPException("flow-names must be unique within an fo:page-sequence");
MessageHandler.log(" [" + currentPageNumber);
if ((status.getCode() == Status.FORCE_PAGE_BREAK_EVEN)
- && ((currentPageNumber % 2) == 1)) {}
+ && ((currentPageNumber % 2) == 1)) {}
else if ((status.getCode() == Status.FORCE_PAGE_BREAK_ODD)
- && ((currentPageNumber % 2) == 0)) {}
+ && ((currentPageNumber % 2) == 0)) {}
else {
BodyAreaContainer bodyArea = currentPage.getBody();
bodyArea.setIDReferences(areaTree.getIDReferences());
MessageHandler.log("]");
areaTree.addPage(currentPage);
this.pageCount++; // used for 'force-page-count' calculations
- } while (flowsAreIncomplete());
+ }
+ while (flowsAreIncomplete());
// handle the 'force-page-count'
forcePage(areaTree, firstAvailPageNumber);
currentPage = null;
-
+
MessageHandler.logln("");
}
// page number is 0-indexed
PageMaster pageMaster = getNextPageMaster(masterName,
- firstAvailPageNumber,
- isFirstPage, isEmptyPage);
+ firstAvailPageNumber,
+ isFirstPage, isEmptyPage);
// a legal alternative is to use the last sub-sequence
// specification which should be handled in getNextSubsequence. That's not done here.
// handle forcing
if (isForcing) {
String nextPageMaster = getNextPageMasterName(sequenceMaster,
- currentPageNumber, false, true);
+ currentPageNumber, false, true);
return this.layoutMasterSet.getSimplePageMaster(nextPageMaster);
}
String nextPageMaster = getNextPageMasterName(sequenceMaster,
- currentPageNumber, thisIsFirstPage, isEmptyPage);
+ currentPageNumber, thisIsFirstPage, isEmptyPage);
return this.layoutMasterSet.getSimplePageMaster(nextPageMaster);
}
currentSubsequence.reset();
// we leave currentSubsequence alone
- } else {
+ }
+ else {
currentSubsequence = nextSubsequence;
}
if (nextSequence != null) {
if (nextSequence.getIpnValue().equals("auto")) {
// do nothing special
- } else if (nextSequence.getIpnValue().equals("auto-odd")) {
+ }
+ else if (nextSequence.getIpnValue().equals("auto-odd")) {
if (firstAvailPageNumber % 2 == 0) {
makePage = true;
}
} else if (this.forcePageCount == ForcePageCount.NO_FORCE) {
// do nothing
}
+
if (makePage) {
try {
this.isForcing = true;
Any extensions added to the AreaTree while generating a page
are given to the Page for the renderer to deal with.
*/
-
+
public class AreaTree {
/**
* List of root extension objects
*/
Vector rootExtensions = null;
-
+
private StreamRenderer streamRenderer;
-
- public AreaTree(StreamRenderer streamRenderer)
- {
- this.streamRenderer = streamRenderer;
+
+ public AreaTree(StreamRenderer streamRenderer) {
+ this.streamRenderer = streamRenderer;
}
-
+
public void setFontInfo(FontInfo fontInfo) {
this.fontInfo = fontInfo;
}
}
public Page getPreviousPage(Page current, boolean isWithinPageSequence,
- boolean isFirstCall) {
+ boolean isFirstCall) {
return current;
}
public void addPage(Page page)
- throws FOPException
- {
+ throws FOPException {
try {
- page.setExtensions(rootExtensions);
- rootExtensions = null;
- streamRenderer.queuePage(page);
- }
- catch (IOException e)
- {
- throw new FOPException(e);
+ page.setExtensions(rootExtensions);
+ rootExtensions = null;
+ streamRenderer.queuePage(page);
+ } catch (IOException e) {
+ throw new FOPException(e);
}
}
return streamRenderer.getIDReferences();
}
- public void addExtension(ExtensionObj obj)
- {
- if(rootExtensions ==null)
- rootExtensions = new Vector();
- rootExtensions.addElement(obj);
+ public void addExtension(ExtensionObj obj) {
+ if(rootExtensions ==null)
+ rootExtensions = new Vector();
+ rootExtensions.addElement(obj);
}
-
+
}
private AreaContainer end;
private AreaTree areaTree;
-
+
private Vector rootExtensions;
-
+
private PageSequence pageSequence;
protected int pageNumber = 0;
markers = new Vector();
}
- public IDReferences getIDReferences()
- {
- return areaTree.getIDReferences();
+ public IDReferences getIDReferences() {
+ return areaTree.getIDReferences();
}
-
+
public void setPageSequence(PageSequence pageSequence) {
this.pageSequence = pageSequence;
}
}
public Vector getExtensions() {
- return rootExtensions;
+ return rootExtensions;
}
public void setExtensions(Vector extensions) {
- this.rootExtensions = extensions;
+ this.rootExtensions = extensions;
}
-
+
public void setPendingFootnotes(Vector v) {
footnotes = v;
if (footnotes != null) {
if (!Footnote.layoutFootnote(this, fb, null)) {
// footnotes are too large to fit on empty page
}
+
}
footnotes = null;
}
protected Vector location = new Vector();
/** List of objects to write in the trailer */
- private Vector trailerObjects = new Vector();
+ private Vector trailerObjects = new Vector();
/**
* the counter for object numbering
/** The root outline object */
private PDFOutline outlineRoot = null;
-
+
/** The /Pages object (mark-fop@inomial.com) */
private PDFPages pages;
-
+
/**
* the /Info object
*/
/* create the /Root, /Info and /Resources objects */
this.pages = makePages();
-
+
// Create the Root object
this.root = makeRoot(pages);
-
+
// Create the Resources object
this.resources = makeResources();
-
+
// Make the /Info record
this.info = makeInfo();
}
* Make a /Catalog (Root) object. This object is written in
* the trailer.
*/
- public PDFRoot makeRoot(PDFPages pages)
- {
+ public PDFRoot makeRoot(PDFPages pages) {
+
+ /*
+ * Make a /Pages object. This object is written in the trailer.
+ */
+ PDFRoot pdfRoot = new PDFRoot(++this.objectcount, pages);
+ addTrailerObject(pdfRoot);
+ return pdfRoot;
+ }
- /*
- * Make a /Pages object. This object is written in the trailer.
- */
- PDFRoot pdfRoot = new PDFRoot(++this.objectcount, pages);
- addTrailerObject(pdfRoot);
- return pdfRoot;
- }
-
/**
* Make a /Pages object. This object is written in the trailer.
*/
-
- public PDFPages makePages()
- {
+
+ public PDFPages makePages() {
PDFPages pdfPages = new PDFPages(++this.objectcount);
addTrailerObject(pdfPages);
return pdfPages;
- }
+ }
/**
* Make a /Resources object. This object is written in the trailer.
*/
- public PDFResources makeResources()
- {
- PDFResources pdfResources = new PDFResources(++this.objectcount);
- addTrailerObject(pdfResources);
- return pdfResources;
- }
+ public PDFResources makeResources() {
+ PDFResources pdfResources = new PDFResources(++this.objectcount);
+ addTrailerObject(pdfResources);
+ return pdfResources;
+ }
/**
* make an /Info object
* @param thePatternDataStream The stream of pattern data to be tiled.
*/
public PDFPattern makePattern(int thePatternType, // 1
- PDFResources theResources, int thePaintType, int theTilingType,
- Vector theBBox, double theXStep, double theYStep, Vector theMatrix,
- Vector theXUID, StringBuffer thePatternDataStream) {
+ PDFResources theResources, int thePaintType, int theTilingType,
+ Vector theBBox, double theXStep, double theYStep, Vector theMatrix,
+ Vector theXUID, StringBuffer thePatternDataStream) {
String thePatternName = new String("Pa" + (++this.patternCount));
// int theNumber, String thePatternName,
// PDFResources theResources
PDFColor currentColor =
(PDFColor)theColors.elementAt(currentPosition);
PDFColor nextColor = (PDFColor)theColors.elementAt(currentPosition
- + 1);
+ + 1);
// colorspace must be consistant
if (this.colorspace.getColorSpace()
!= currentColor.getColorSpace())
((org.apache.fop.render.pdf.Font)metrics).getSubType();
PDFFontDescriptor pdfdesc = makeFontDescriptor(descriptor,
- subtype);
+ subtype);
PDFFontNonBase14 font = null;
if (subtype == PDFFont.TYPE0) {
* make a /FontDescriptor object
*/
public PDFFontDescriptor makeFontDescriptor(FontDescriptor desc,
- byte subtype) {
+ byte subtype) {
PDFFontDescriptor font = null;
if (subtype == PDFFont.TYPE0) {
desc.fontName(),
desc.getFontBBox(),
// desc.getAscender(),
- // desc.getDescender(),
- desc.getCapHeight(), desc.getFlags(),
- // new PDFRectangle(desc.getFontBBox()),
- desc.getItalicAngle(), desc.getStemV(), null); // desc.getLang(),
+ // desc.getDescender(),
+ desc.getCapHeight(), desc.getFlags(),
+ // new PDFRectangle(desc.getFontBBox()),
+ desc.getItalicAngle(), desc.getStemV(), null); // desc.getLang(),
// null);//desc.getPanose());
- } else {
+ }
+ else {
// Create normal FontDescriptor
font = new PDFFontDescriptor(++this.objectcount, desc.fontName(),
desc.getAscender(),
PDFXObject xObject = (PDFXObject)this.xObjectsMap.get(url);
if (xObject != null)
return xObject.getXNumber();
- // else, create a new one
+ // else, create a new one
xObject = new PDFXObject(++this.objectcount, ++this.xObjectCount,
img);
this.objects.addElement(xObject);
while (enum.hasMoreElements()) {
String id = enum.nextElement().toString();
idReferences.setInternalGoToPageReference(id,
- page.referencePDF());
+ page.referencePDF());
}
}
idReferences.createNewId(destination);
idReferences.addToIdValidationList(destination);
goToReference = idReferences.createInternalLinkGoTo(destination,
- ++this.objectcount);
+ ++this.objectcount);
addTrailerObject(idReferences.getPDFGoTo(destination));
}
return goToReference;
}
-
- public void addTrailerObject(PDFObject object)
- {
- this.trailerObjects.addElement(object);
+
+ public void addTrailerObject(PDFObject object) {
+ this.trailerObjects.addElement(object);
}
-
+
/**
Ensure there is room in the locations xref for the number of
objects that have been created.
*/
- private void prepareLocations()
- {
- while(location.size() < objectcount)
- location.addElement(locationPlaceholder);
+ private void prepareLocations() {
+ while(location.size() < objectcount)
+ location.addElement(locationPlaceholder);
}
/**
* reference for later.
*/
public PDFOutline getOutlineRoot() {
- if(outlineRoot != null)
+ if(outlineRoot != null)
+ return outlineRoot;
+
+ outlineRoot = new PDFOutline(++this.objectcount, null, null);
+ addTrailerObject(outlineRoot);
+ root.setRootOutline(outlineRoot);
return outlineRoot;
-
- outlineRoot = new PDFOutline(++this.objectcount, null, null);
- addTrailerObject(outlineRoot);
- root.setRootOutline(outlineRoot);
- return outlineRoot;
}
/**
*
* @param writer the OutputStream to output the document to
*/
- public void output(OutputStream stream) throws IOException
- {
+ public void output(OutputStream stream) throws IOException {
prepareLocations();
* locations
*/
location.setElementAt(
- new Integer(this.position),object.getNumber() - 1);
+ new Integer(this.position),object.getNumber() - 1);
/*
* output the object and increment the character position
* @return the number of bytes written
*/
public void outputHeader(OutputStream stream)
- throws IOException
- {
+ throws IOException {
this.position=0;
-
+
byte[] pdf = ("%PDF-" + this.pdfVersion + "\n").getBytes();
stream.write(pdf);
this.position += pdf.length;
* @param stream the OutputStream to write the trailer to
*/
public void outputTrailer(OutputStream stream)
- throws IOException
- {
- output(stream);
- Enumeration e = trailerObjects.elements();
- while(e.hasMoreElements())
- {
- PDFObject o = (PDFObject) e.nextElement();
- this.location.setElementAt(
- new Integer(this.position), o.getNumber() - 1);
- this.position += o.output(stream);
- }
+ throws IOException {
+ output(stream);
+ Enumeration e = trailerObjects.elements();
+ while(e.hasMoreElements()) {
+ PDFObject o = (PDFObject) e.nextElement();
+ this.location.setElementAt(
+ new Integer(this.position), o.getNumber() - 1);
+ this.position += o.output(stream);
+ }
/* output the xref table and increment the character position
by the table's length */
this.position += outputXref(stream);
-
+
/* construct the trailer */
- String pdf =
- "trailer\n" +
- "<<\n" +
- "/Size " + (this.objectcount + 1) + "\n" +
- "/Root " + this.root.number + " " + this.root.generation + " R\n" +
- "/Info " + this.info.number + " " + this.info.generation + " R\n" +
- ">>\n" +
- "startxref\n" +
- this.xref + "\n" +
- "%%EOF\n";
+ String pdf =
+ "trailer\n" +
+ "<<\n" +
+ "/Size " + (this.objectcount + 1) + "\n" +
+ "/Root " + this.root.number + " " + this.root.generation + " R\n" +
+ "/Info " + this.info.number + " " + this.info.generation + " R\n" +
+ ">>\n" +
+ "startxref\n" +
+ this.xref + "\n" +
+ "%%EOF\n";
/* write the trailer */
stream.write(pdf.getBytes());
*
* @return the PDF string
*/
- public byte[] toPDF()
- {
+ public byte[] toPDF() {
StringBuffer p = new StringBuffer(this.number + " " + this.generation
+ " obj\n<< /Type /Pages\n/Count "
+ this.getCount() + "\n/Kids [");
super(number);
setRootPages(pages);
}
-
+
/**
* Before the root is written to the document stream,
* make sure it's object number is set. Package-private access
* only; outsiders should not be fiddling with this stuff.
*/
void setNumber(int number) {
- this.number = number;
+ this.number = number;
}
/**
_outline = outline;
}
- public PDFOutline getRootOutline()
- {
- return _outline;
- }
+ public PDFOutline getRootOutline() {
+ return _outline;
+ }
/**
* @return the PDF string
*/
public byte[] toPDF()
- throws IllegalStateException
- {
+ throws IllegalStateException {
StringBuffer p = new StringBuffer(this.number + " " + this.generation
+ " obj\n<< /Type /Catalog\n/Pages "
+ this.rootPages.referencePDF()
* @param g the green component
* @param b the blue component
*/
- protected abstract void addLine(int x1, int y1, int x2, int y2, int th,
+ protected abstract void addLine(int x1, int y1, int x2, int y2, int th,
PDFPathPaint stroke);
/**
* @param g the green component
* @param b the blue component
*/
- protected abstract void addLine(int x1, int y1, int x2, int y2, int th,
+ protected abstract void addLine(int x1, int y1, int x2, int y2, int th,
int rs, PDFPathPaint stroke);
/**
* @param h the height in millipoints
* @param stroke the stroke color/gradient
*/
- protected abstract void addRect(int x, int y, int w, int h,
+ protected abstract void addRect(int x, int y, int w, int h,
PDFPathPaint stroke);
/**
* @param fill the fill color/gradient
* @param stroke the stroke color/gradient
*/
- protected abstract void addRect(int x, int y, int w, int h,
+ protected abstract void addRect(int x, int y, int w, int h,
PDFPathPaint stroke, PDFPathPaint fill);
/**
* @param h the height in millipoints
* @param fill the fill color/gradient
*/
- protected void addFilledRect(int x, int y, int w, int h,
+ protected void addFilledRect(int x, int y, int w, int h,
PDFPathPaint fill) {
addRect(x, y, w, h, fill, fill);
- }
+ }
/**
* render area container
this.currentYPosition -= area.getYPosition();
this.currentAreaContainerXPosition += area.getXPosition();
} else if (area.getPosition() == Position.STATIC) {
- this.currentYPosition -= area.getPaddingTop()
+ this.currentYPosition -= area.getPaddingTop()
+ area.getBorderTopWidth();
/*
* this.currentAreaContainerXPosition +=
* area.getPaddingLeft() + area.getBorderLeftWidth();
*/
- }
+ }
this.currentXPosition = this.currentAreaContainerXPosition;
doFrame(area);
while (e.hasMoreElements()) {
Box b = (Box)e.nextElement();
b.render(this);
- }
+ }
// Restore previous origin
this.currentYPosition = saveY;
this.currentAreaContainerXPosition = saveX;
if (area.getPosition() == Position.STATIC) {
this.currentYPosition -= area.getHeight();
- }
+ }
/**
* **
* this.currentYPosition -= area.getHeight();
* **
*/
- }
+ }
public void renderBodyAreaContainer(BodyAreaContainer area) {
int saveY = this.currentYPosition;
} else if (area.getPosition() == Position.RELATIVE) {
this.currentYPosition -= area.getYPosition();
this.currentAreaContainerXPosition += area.getXPosition();
- }
+ }
this.currentXPosition = this.currentAreaContainerXPosition;
int w, h;
// but I do
if ((bg != null) && (bg.alpha() == 0)) {
this.addRect(rx, ry, w, -h, new PDFColor(bg), new PDFColor(bg));
- }
+ }
// floats & footnotes stuff
renderAreaContainer(area.getBeforeFloatReferenceArea());
while (e.hasMoreElements()) {
Box b = (Box)e.nextElement();
b.render(this); // span areas
- }
+ }
+
if (area.getPosition() != Position.STATIC) {
this.currentYPosition = saveY;
} else
this.currentYPosition -= area.getHeight();
- }
+ }
public void renderSpanArea(SpanArea area) {
Enumeration e = area.getChildren().elements();
while (e.hasMoreElements()) {
Box b = (Box)e.nextElement();
b.render(this); // column areas
- }
- }
+ }
+
+ }
private void doFrame(Area area) {
int w, h;
// but I do
if ((bg != null) && (bg.alpha() == 0)) {
this.addFilledRect(rx, ry, w, -h, new PDFColor(bg));
- }
+ }
// rx = rx - area.getBorderLeftWidth();
// ry = ry + area.getBorderTopWidth();
int bottom = area.getBorderBottomWidth();
// If style is solid, use filled rectangles
if (top != 0)
- addFilledRect(rx, ry, w, top,
+ addFilledRect(rx, ry, w, top,
new PDFColor(bp.getBorderColor(BorderAndPadding.TOP)));
if (left != 0)
- addFilledRect(rx - left, ry - h - bottom, left, h + top + bottom,
+ addFilledRect(rx - left, ry - h - bottom, left, h + top + bottom,
new PDFColor(bp.getBorderColor(BorderAndPadding.LEFT)));
if (right != 0)
- addFilledRect(rx + w, ry - h - bottom, right, h + top + bottom,
+ addFilledRect(rx + w, ry - h - bottom, right, h + top + bottom,
new PDFColor(bp.getBorderColor(BorderAndPadding.RIGHT)));
if (bottom != 0)
- addFilledRect(rx, ry - h - bottom, w, bottom,
+ addFilledRect(rx, ry - h - bottom, w, bottom,
new PDFColor(bp.getBorderColor(BorderAndPadding.BOTTOM)));
- }
+ }
/**
public void renderBlockArea(BlockArea area) {
// KLease: Temporary test to fix block positioning
// Offset ypos by padding and border widths
- this.currentYPosition -= (area.getPaddingTop()
+ this.currentYPosition -= (area.getPaddingTop()
+ area.getBorderTopWidth());
doFrame(area);
Enumeration e = area.getChildren().elements();
while (e.hasMoreElements()) {
Box b = (Box)e.nextElement();
b.render(this);
- }
- this.currentYPosition -= (area.getPaddingBottom()
+ }
+ this.currentYPosition -= (area.getPaddingBottom()
+ area.getBorderBottomWidth());
- }
+ }
/**
* render display space
public void renderDisplaySpace(DisplaySpace space) {
int d = space.getSize();
this.currentYPosition -= d;
- }
+ }
/**
* render image area
*/
public abstract void renderWordArea(WordArea area);
- protected void addWordLines(WordArea area, int rx, int bl, int size,
+ protected void addWordLines(WordArea area, int rx, int bl, int size,
PDFColor theAreaColor) {
if (area.getUnderlined()) {
int yPos = bl - size / 10;
- addLine(rx, yPos, rx + area.getContentWidth(), yPos, size / 14,
+ addLine(rx, yPos, rx + area.getContentWidth(), yPos, size / 14,
theAreaColor);
// save position for underlining a following InlineSpace
prevUnderlineXEndPos = rx + area.getContentWidth();
prevUnderlineYEndPos = yPos;
prevUnderlineSize = size / 14;
prevUnderlineColor = theAreaColor;
- }
+ }
if (area.getOverlined()) {
int yPos = bl + area.getFontState().getAscender() + size / 10;
- addLine(rx, yPos, rx + area.getContentWidth(), yPos, size / 14,
+ addLine(rx, yPos, rx + area.getContentWidth(), yPos, size / 14,
theAreaColor);
prevOverlineXEndPos = rx + area.getContentWidth();
prevOverlineYEndPos = yPos;
prevOverlineSize = size / 14;
prevOverlineColor = theAreaColor;
- }
+ }
if (area.getLineThrough()) {
int yPos = bl + area.getFontState().getAscender() * 3 / 8;
- addLine(rx, yPos, rx + area.getContentWidth(), yPos, size / 14,
+ addLine(rx, yPos, rx + area.getContentWidth(), yPos, size / 14,
theAreaColor);
prevLineThroughXEndPos = rx + area.getContentWidth();
prevLineThroughYEndPos = yPos;
prevLineThroughSize = size / 14;
prevLineThroughColor = theAreaColor;
- }
- }
+ }
+ }
/**
* render inline space
this.currentXPosition += space.getSize();
if (space.getUnderlined()) {
if (prevUnderlineColor != null) {
- addLine(prevUnderlineXEndPos, prevUnderlineYEndPos,
- prevUnderlineXEndPos + space.getSize(),
- prevUnderlineYEndPos, prevUnderlineSize,
+ addLine(prevUnderlineXEndPos, prevUnderlineYEndPos,
+ prevUnderlineXEndPos + space.getSize(),
+ prevUnderlineYEndPos, prevUnderlineSize,
prevUnderlineColor);
- }
- }
+ }
+ }
if (space.getOverlined()) {
if (prevOverlineColor != null) {
- addLine(prevOverlineXEndPos, prevOverlineYEndPos,
- prevOverlineXEndPos + space.getSize(),
- prevOverlineYEndPos, prevOverlineSize,
+ addLine(prevOverlineXEndPos, prevOverlineYEndPos,
+ prevOverlineXEndPos + space.getSize(),
+ prevOverlineYEndPos, prevOverlineSize,
prevOverlineColor);
- }
- }
+ }
+ }
if (space.getLineThrough()) {
if (prevLineThroughColor != null) {
- addLine(prevLineThroughXEndPos, prevLineThroughYEndPos,
- prevLineThroughXEndPos + space.getSize(),
- prevLineThroughYEndPos, prevLineThroughSize,
+ addLine(prevLineThroughXEndPos, prevLineThroughYEndPos,
+ prevLineThroughXEndPos + space.getSize(),
+ prevLineThroughYEndPos, prevLineThroughSize,
prevLineThroughColor);
- }
- }
- }
+ }
+ }
+ }
/**
* render line area
this.currentYPosition = ry - ia.getYOffset();
} else {
this.currentYPosition = ry - area.getPlacementOffset();
- }
+ }
b.render(this);
- }
+ }
this.currentYPosition = ry - h;
this.currentXPosition = rx;
- }
+ }
/**
* render page
if (th != 0) {
switch (st) {
case org.apache.fop.fo.properties.RuleStyle.DOUBLE:
- addLine(rx, ry, rx + w, ry, th / 3, st,
- new PDFColor(area.getRed(), area.getGreen(),
+ addLine(rx, ry, rx + w, ry, th / 3, st,
+ new PDFColor(area.getRed(), area.getGreen(),
area.getBlue()));
- addLine(rx, ry + (2 * th / 3), rx + w, ry + (2 * th / 3),
- th / 3, st,
- new PDFColor(area.getRed(), area.getGreen(),
+ addLine(rx, ry + (2 * th / 3), rx + w, ry + (2 * th / 3),
+ th / 3, st,
+ new PDFColor(area.getRed(), area.getGreen(),
area.getBlue()));
break;
case org.apache.fop.fo.properties.RuleStyle.GROOVE:
- addLine(rx, ry, rx + w, ry, th / 2, st,
- new PDFColor(area.getRed(), area.getGreen(),
+ addLine(rx, ry, rx + w, ry, th / 2, st,
+ new PDFColor(area.getRed(), area.getGreen(),
area.getBlue()));
- addLine(rx, ry + (th / 2), rx + w, ry + (th / 2), th / 2, st,
+ addLine(rx, ry + (th / 2), rx + w, ry + (th / 2), th / 2, st,
new PDFColor(255, 255, 255));
break;
case org.apache.fop.fo.properties.RuleStyle.RIDGE:
- addLine(rx, ry, rx + w, ry, th / 2, st,
+ addLine(rx, ry, rx + w, ry, th / 2, st,
new PDFColor(255, 255, 255));
- addLine(rx, ry + (th / 2), rx + w, ry + (th / 2), th / 2, st,
- new PDFColor(area.getRed(), area.getGreen(),
+ addLine(rx, ry + (th / 2), rx + w, ry + (th / 2), th / 2, st,
+ new PDFColor(area.getRed(), area.getGreen(),
area.getBlue()));
break;
default:
- addLine(rx, ry, rx + w, ry, th, st,
- new PDFColor(area.getRed(), area.getGreen(),
+ addLine(rx, ry, rx + w, ry, th, st,
+ new PDFColor(area.getRed(), area.getGreen(),
area.getBlue()));
}
this.currentXPosition += area.getContentWidth();
this.currentYPosition += th;
- }
- }
+ }
+ }
/**
* set up the font info
public void setupFontInfo(FontInfo fontInfo) {
this.fontInfo = fontInfo;
FontSetup.setup(fontInfo);
- }
-
+ }
+
/**
Default start renderer method. This would
normally be overridden. (mark-fop@inomial.com).
*/
public void startRenderer(OutputStream outputStream)
- throws IOException
- {
- }
+ throws IOException {}
/**
Default stop renderer method. This would
normally be overridden. (mark-fop@inomial.com).
*/
//public void render(AreaTree areaTree, OutputStream stream) throws IOException, FOPException;
public void render(Page page, OutputStream stream)
- throws IOException, FOPException;
+ throws IOException, FOPException;
/**
* render the given area container
public void renderLeaderArea(LeaderArea area);
public void startRenderer(OutputStream outputStream)
- throws IOException;
-
+ throws IOException;
+
public void stopRenderer(OutputStream outputStream)
- throws IOException;
+ throws IOException;
}
protected Color saveColor = null;
protected IDReferences idReferences = null;
-
+
/**
* Image Object and Graphics Object. The Graphics Object is the Graphics
* object that is contained withing the Image Object.
int y = y1;
int height, width;
if (x1 == x2) // vertical line
- {
+ {
height = y2 - y1;
if (height > 0) // y coordinates are reversed between fo and AWT
- {
+ {
height = -height;
y = y2;
}
x -= width;
}
} else // horizontal line
- {
+ {
width = x2 - x1;
if (width < 0) {
width = -width;
}
height = th;
if (height > 0) // y coordinates are reversed between fo and AWT
- {
+ {
height = -height;
y -= height;
}
// changed by aml/rlc to use helper function that
// corrects for integer roundoff, and to remove 3D effect
+
protected void addRect(int x, int y, int w, int h, float r, float g,
float b) {
graphics.setColor(new Color(r, g, b));
}
public void removePage(int page) {
- pageList.removeElementAt(page);
+ pageList.removeElementAt(page);
}
- public void render(int aPageNumber)
- {
- if(aPageNumber >= pageList.size())
- return;
-
- try{
- render((Page) pageList.elementAt(aPageNumber));
- } catch(IOException e){
- e.printStackTrace();
- // This exception can't occur because we are not dealing with
- // any files
- }
+ public void render(int aPageNumber) {
+ if(aPageNumber >= pageList.size())
+ return;
+
+ try {
+ render((Page) pageList.elementAt(aPageNumber));
+ } catch(IOException e) {
+ e.printStackTrace();
+ // This exception can't occur because we are not dealing with
+ // any files
+ }
+
}
public void render(Page page, OutputStream stream)
- throws IOException
- {
- pageList.addElement(page);
+ throws IOException {
+ pageList.addElement(page);
}
public void render(Page page)
- throws IOException
- {
- idReferences = page.getIDReferences();
+ throws IOException {
+ idReferences = page.getIDReferences();
pageWidth = (int)((float)page.getWidth() / 1000f + .5);
pageHeight = (int)((float)page.getHeight() / 1000f + .5);
(org.apache.fop.layout.Box)e.nextElement();
b.render(this); // span areas
}
+
}
// empty for now
(org.apache.fop.layout.Box)e.nextElement();
b.render(this); // column areas
}
+
}
private void doFrame(org.apache.fop.layout.Area area) {
borderColor = bp.getBorderColor(BorderAndPadding.RIGHT);
addLine(rx + w, ry, rx + w, ry - h,
// area.getBorderRightWidth(), borderColor.red(), // corrected aml/rlc
- -area.getBorderRightWidth(), borderColor.red(),
- borderColor.green(),
- borderColor.blue());
+ -area.getBorderRightWidth(), borderColor.red(),
+ borderColor.green(),
+ borderColor.blue());
}
if (area.getBorderBottomWidth() != 0) {
java.awt.Font f = graphics.getFont();
java.awt.Font smallFont = new java.awt.Font(f.getFontName(),
- f.getStyle(), 8);
+ f.getStyle(), 8);
graphics.setFont(smallFont);
SVGDocument svg = ((SVGImage)img).getSVGDocument();
renderSVGDocument(svg, (int)x, (int)y);
} catch (FopImageException e) {}
+
} else {
String urlString = img.getURL();
// cannot normally occur because, if URL is wrong, constructing FopImage
// will already have failed earlier on
}
+
}
}
// defined in Renderer Interface
}
+
public int print(Graphics g, PageFormat pageFormat,
int pageIndex) throws PrinterException {
if (pageIndex >= pageList.size())
}
public PageFormat getPageFormat(int pageIndex)
- throws IndexOutOfBoundsException {
+ throws IndexOutOfBoundsException {
if (pageIndex >= pageList.size())
return null;
}
public Printable getPrintable(int pageIndex)
- throws IndexOutOfBoundsException {
+ throws IndexOutOfBoundsException {
return this;
}
// application.openLink(uri);
}
+
public Point getClientAreaLocationOnScreen() {
return new Point(0, 0);
}
public void setSVGCursor(java.awt.Cursor cursor) {}
+
public AffineTransform getTransform() {
return currentTransform;
}
public void registerExtension(BridgeExtension be) {}
+
}
-
+
public void startRenderer(OutputStream outputStream)
- throws IOException
- {
- }
-
+ throws IOException {}
+
+
public void stopRenderer(OutputStream outputStream)
- throws IOException
- {
- render(0);
+ throws IOException {
+ render(0);
}
-
+
}
*/
public void setProducer(String producer) {}
+
public void renderAreaContainer(AreaContainer area) {
if (area.foCreator != null
b.render(this); // span areas
}
+
if (area.getPosition() != Position.STATIC) {
this.currentYPosition = saveY;
this.currentAreaContainerXPosition = saveX;
Box b = (Box)e.nextElement();
b.render(this); // column areas
}
+
}
/**
*/
public void renderForeignObjectArea(ForeignObjectArea area) {}
+
public void renderWordArea(WordArea area) {
String s;
s = area.getText();
normally be overridden. (mark-fop@inomial.com).
*/
public void startRenderer(OutputStream outputStream)
- throws IOException
- {
- MessageHandler.logln("rendering areas to MIF");
+ throws IOException {
+ MessageHandler.logln("rendering areas to MIF");
}
-
+
/**
Default stop renderer method. This would
normally be overridden. (mark-fop@inomial.com)
*/
public void stopRenderer(OutputStream outputStream)
- throws IOException
- {
- MessageHandler.logln("writing out MIF");
- this.mifDoc.output(outputStream);
- outputStream.flush();
+ throws IOException {
+ MessageHandler.logln("writing out MIF");
+ this.mifDoc.output(outputStream);
+ outputStream.flush();
}
public void render(Page page, OutputStream outputStream) {
- this.renderPage(page);
+ this.renderPage(page);
}
}
* @param producer string indicating application producing PCL
*/
public void setProducer(String producer) {}
-
+
/**
* add a line to the current stream
*
resolution = 75;
if (debug)
System.out.println("PCLRenderer.printBMP() iscolor = " + iscolor);
- // Setup for graphics
+ // Setup for graphics
currentStream.add("\033*t" + resolution + "R\033*r0F\033*r1A");
// Transfer graphics data
indx = iy * iw;
if (iscolor)
indx *= 3;
- // currentStream.add("\033*b" + bytewidth + "W");
+ // currentStream.add("\033*b" + bytewidth + "W");
for (ix = 0; ix < iw; ix++) {
if (iscolor) {
cr = imgmap[indx++] & 0xFF;
// currentStream.add("Q\n");
}
+
public void setFont(String name, float size) {
int fontcode = 0;
if (name.length() > 1 && name.charAt(0) == 'F') {
case 1: // F1 = Helvetica
// currentStream.add("\033(8U\033(s1p" + (size / 1000) + "v0s0b24580T");
// Arial is more common among PCL5 printers than Helvetica - so use Arial
+
currentStream.add("\033(0N\033(s1p" + (size / 1000)
+ "v0s0b16602T");
break;
case 2: // F2 = Helvetica Oblique
+
currentStream.add("\033(0N\033(s1p" + (size / 1000)
+ "v1s0b16602T");
break;
case 3: // F3 = Helvetica Bold
+
currentStream.add("\033(0N\033(s1p" + (size / 1000)
+ "v0s3b16602T");
break;
case 4: // F4 = Helvetica Bold Oblique
+
currentStream.add("\033(0N\033(s1p" + (size / 1000)
+ "v1s3b16602T");
break;
case 5: // F5 = Times Roman
// currentStream.add("\033(8U\033(s1p" + (size / 1000) + "v0s0b25093T");
// Times New is more common among PCL5 printers than Times - so use Times New
+
currentStream.add("\033(0N\033(s1p" + (size / 1000)
+ "v0s0b16901T");
break;
case 6: // F6 = Times Italic
+
currentStream.add("\033(0N\033(s1p" + (size / 1000)
+ "v1s0b16901T");
break;
case 7: // F7 = Times Bold
+
currentStream.add("\033(0N\033(s1p" + (size / 1000)
+ "v0s3b16901T");
break;
case 8: // F8 = Times Bold Italic
+
currentStream.add("\033(0N\033(s1p" + (size / 1000)
+ "v1s3b16901T");
break;
case 9: // F9 = Courier
+
currentStream.add("\033(0N\033(s0p"
+ (120.01f / (size / 1000.00f)) + "h0s0b4099T");
break;
case 10: // F10 = Courier Oblique
+
currentStream.add("\033(0N\033(s0p"
+ (120.01f / (size / 1000.00f)) + "h1s0b4099T");
break;
case 11: // F11 = Courier Bold
+
currentStream.add("\033(0N\033(s0p"
+ (120.01f / (size / 1000.00f)) + "h0s3b4099T");
break;
case 12: // F12 = Courier Bold Oblique
+
currentStream.add("\033(0N\033(s0p"
+ (120.01f / (size / 1000.00f)) + "h1s3b4099T");
break;
case 13: // F13 = Symbol
+
currentStream.add("\033(19M\033(s1p" + (size / 1000)
+ "v0s0b16686T");
// currentStream.add("\033(9U\033(s1p" + (size / 1000) + "v0s0b25093T"); // ECMA Latin 1 Symbol Set in Times Roman???
break;
case 14: // F14 = Zapf Dingbats
+
currentStream.add("\033(14L\033(s1p" + (size / 1000)
+ "v0s0b45101T");
break;
System.out.println("PCLRenderer.renderPage() paperheight="
+ paperheight + " divisions=" + divisions);
- // Set top margin.
- // float fullmargin = 0;
+ // Set top margin.
+ // float fullmargin = 0;
if (divisions > 0)
fullmargin = paperheight * curdiv / divisions;
if (topmargin > 0)
if (debug)
System.out.println("PCLRenderer.renderPage() curdiv=" + curdiv
+ " fullmargin=" + fullmargin);
- // if ( fullmargin > 0 )
- // currentStream.add("\033&l" + (fullmargin / 15f) + "c1e8C");
- // this.currentYPosition = fullmargin * 100;
+ // if ( fullmargin > 0 )
+ // currentStream.add("\033&l" + (fullmargin / 15f) + "c1e8C");
+ // this.currentYPosition = fullmargin * 100;
if (paperheight > 0)
pageHeight = (paperheight / divisions) + fullmargin;
if (end != null)
renderAreaContainer(end);
- // End page.
+ // End page.
if (++curdiv == divisions || divisions == -1) {
curdiv = 0;
currentStream.add("\f");
*/
}
public void startRenderer(OutputStream outputStream)
- throws IOException
- { MessageHandler.logln("rendering areas to PCL");
+ throws IOException {
+ MessageHandler.logln("rendering areas to PCL");
currentStream = new PCLStream(outputStream);
// Set orientation.
// Reset the margins.
currentStream.add("\033" + "9\033&l0E");
}
-
+
public void stopRenderer(OutputStream outputStream)
- throws IOException
- {
+ throws IOException {
MessageHandler.logln("writing out PCL");
outputStream.flush();
}
public void render(Page page, OutputStream outputStream)
- throws IOException
- {
+ throws IOException {
idReferences = page.getIDReferences();
- this.renderPage(page);
+ this.renderPage(page);
}
}
}
public void startRenderer(OutputStream stream)
- throws IOException
- {
- pdfDoc.outputHeader(stream);
+ throws IOException {
+ pdfDoc.outputHeader(stream);
}
public void stopRenderer(OutputStream stream)
- throws IOException
- {
- pdfDoc.outputTrailer(stream);
+ throws IOException {
+ pdfDoc.outputTrailer(stream);
}
-
+
/**
* add a line to the current stream
*
renderSVGDocument(svg, (int)x, (int)y, area.getFontState());
currentStream.add("Q\nBT\n");
} catch (FopImageException e) {}
+
} else {
int xObjectNum = this.pdfDoc.addImage(img);
closeText();
ctx.putBridge(aBridge);
GraphicsNode root;
PDFGraphics2D graphics = new PDFGraphics2D(true, fs, pdfDoc,
- currentFontName,
- currentFontSize,
- currentXPosition,
- currentYPosition);
+ currentFontName,
+ currentFontSize,
+ currentXPosition,
+ currentYPosition);
graphics.setGraphicContext(new org.apache.batik.ext.awt.g2d.GraphicContext());
graphics.setRenderingHints(rc.getRenderingHints());
aBridge.setPDFGraphics2D(graphics);
(Font)area.getFontState().getFontInfo().getFonts().get(name);
if (f instanceof CIDFont)
useMultiByte = true;
- // String startText = useMultiByte ? "<FEFF" : "(";
+ // String startText = useMultiByte ? "<FEFF" : "(";
String startText = useMultiByte ? "<" : "(";
String endText = useMultiByte ? "> " : ") ";
// This should never fail
}
+
for (int i = 0; i < uniBytes.length; i++) {
int b = (uniBytes[i] < 0) ? (int)(256 + uniBytes[i])
: (int)uniBytes[i];
}
public void render(Page page, OutputStream outputStream)
- throws FOPException, IOException
- {
- // MessageHandler.logln("rendering single page to PDF");
- this.idReferences = page.getIDReferences();
- this.pdfResources = this.pdfDoc.getResources();
- this.pdfDoc.setIDReferences(idReferences);
- this.renderPage(page);
+ throws FOPException, IOException {
+ // MessageHandler.logln("rendering single page to PDF");
+ this.idReferences = page.getIDReferences();
+ this.pdfResources = this.pdfDoc.getResources();
+ this.pdfDoc.setIDReferences(idReferences);
+ this.renderPage(page);
- FontSetup.addToResources(this.pdfDoc, fontInfo);
+ FontSetup.addToResources(this.pdfDoc, fontInfo);
- // TODO: this needs to be implemented
- renderRootExtensions(page);
+ // TODO: this needs to be implemented
+ renderRootExtensions(page);
- // MessageHandler.logln("writing out PDF");
- this.pdfDoc.output(outputStream);
+ // MessageHandler.logln("writing out PDF");
+ this.pdfDoc.output(outputStream);
}
/**
while (f.hasMoreElements()) {
LinkedRectangle lrect = (LinkedRectangle)f.nextElement();
currentAnnotList.addLink(this.pdfDoc.makeLink(lrect.getRectangle(),
- dest, linkType));
+ dest, linkType));
}
}
} else {
// application.openLink(uri);
}
+
public Point getClientAreaLocationOnScreen() {
return new Point(0, 0);
}
public void setSVGCursor(java.awt.Cursor cursor) {}
+
public AffineTransform getTransform() {
return currentTransform;
}
public void registerExtension(BridgeExtension be) {}
+
}
}
BridgeContext ctx = new BridgeContext(userAgent, rc);
GraphicsNode root;
PSGraphics2D graphics = new PSGraphics2D(false, area.getFontState(),
- this, currentFontName,
- currentFontSize,
- currentXPosition,
- currentYPosition);
+ this, currentFontName,
+ currentFontSize,
+ currentXPosition,
+ currentYPosition);
graphics.setGraphicContext(new org.apache.batik.ext.awt.g2d.GraphicContext());
graphics.setRenderingHints(rc.getRenderingHints());
try {
// e.printStackTrace();
}
+
write("grestore");
comment("% --- SVG Area end");
switch (area.getLeaderPattern()) {
case LeaderPattern.SPACE:
// NOP
+
break;
case LeaderPattern.RULE:
if (area.getRuleStyle() == RuleStyle.NONE)
// application.openLink(uri);
}
+
public Point getClientAreaLocationOnScreen() {
return new Point(0, 0);
}
public void setSVGCursor(java.awt.Cursor cursor) {}
+
public AffineTransform getTransform() {
return currentTransform;
}
public void registerExtension(BridgeExtension be) {}
+
}
/**
Default start renderer method. This would
normally be overridden. (mark-fop@inomial.com).
- */
+ */
public void startRenderer(OutputStream outputStream)
- throws IOException
- {
+ throws IOException {
MessageHandler.logln("rendering areas to PostScript");
-
+
this.out = new PSStream(outputStream);
write("%!PS-Adobe-3.0");
write("%%Creator: "+this.producer);
write("%%EndSetup");
write("FOPFonts begin");
}
-
+
/**
Default stop renderer method. This would
normally be overridden. (mark-fop@inomial.com).
*/
public void stopRenderer(OutputStream outputStream)
- throws IOException
- {
+ throws IOException {
write("%%Trailer");
write("%%EOF");
this.out.flush();
}
public void render(Page page, OutputStream outputStream) {
- this.renderPage(page);
- }
+ this.renderPage(page);
+ }
}
*/
public void setProducer(String producer) {}
+
void addStr(int row, int col, String str, boolean ischar) {
if (debug)
System.out.println("TXTRenderer.addStr(" + row + ", " + col
PDFColor fc, PDFColor sc, float sw,
boolean close) {}
+
boolean printBMP(FopImage img, int x, int y, int w,
int h) throws FopImageException {
if (debug)
if (iname.length() >= namew)
addStr((int)((pageHeight - (y / 100)) * 100 * yFactor)
+ nameh, (int)(x * xFactor),
- iname.substring(iname.length() - namew),
- true);
+ iname.substring(iname.length() - namew),
+ true);
else
addStr((int)((pageHeight - (y / 100)) * 100 * yFactor)
+ nameh, (int)(x * xFactor
+ (namew - iname.length())
- / 2), iname, true);
+ / 2), iname, true);
}
}
// this.currentYPosition -= area.getEffectiveHeight();
}
+
void renderSVG(FontState fontState, SVGSVGElement svg, int x, int y) {
/*
* SVG - Not yet implemented
if (end != null)
renderAreaContainer(end);
- // Write out the buffers.
+ // Write out the buffers.
for (int row = 0; row <= maxY; row++) {
StringBuffer cr = charData[row];
StringBuffer dr = decoData[row];
*/
}
public void startRenderer(OutputStream outputStream)
- throws IOException
- {
- MessageHandler.logln("rendering areas to TEXT");
- currentStream = new PCLStream(outputStream);
- firstPage=true;
+ throws IOException {
+ MessageHandler.logln("rendering areas to TEXT");
+ currentStream = new PCLStream(outputStream);
+ firstPage=true;
}
-
- /**
- * In Mark's patch, this is endRenderer
- * However, I couldn't see how it builds that way, so
- * i changed it. - Steve gears@apache.org
- */
+
+ /**
+ * In Mark's patch, this is endRenderer
+ * However, I couldn't see how it builds that way, so
+ * i changed it. - Steve gears@apache.org
+ */
public void stopRenderer(OutputStream outputStream)
- throws IOException
- {
+ throws IOException {
MessageHandler.logln("writing out TEXT");
outputStream.flush();
}
- public void render(Page page, OutputStream outputStream)
- {
- idReferences = page.getIDReferences();
-
- if ( firstPage )
- firstPage = false;
- else
- currentStream.add(pageEnding);
- this.renderPage(page);
- currentStream.add(lineEnding);
- }
+ public void render(Page page, OutputStream outputStream) {
+ idReferences = page.getIDReferences();
+
+ if ( firstPage )
+ firstPage = false;
+ else
+ currentStream.add(pageEnding);
+ this.renderPage(page);
+ currentStream.add(lineEnding);
+ }
}
this.producer = producer;
}
-
+
public void render(Page page, OutputStream outputStream)
- throws IOException
- {
- this.renderPage(page);
- }
+ throws IOException {
+ this.renderPage(page);
+ }
/**
* write out spaces to make indent
private boolean isCoarseXml() {
return ((Boolean)options.get("fineDetail")).booleanValue();
}
-
+
/**
Default start renderer method. This would
normally be overridden. (mark-fop@inomial.com).
*/
public void startRenderer(OutputStream outputStream)
- throws IOException
- {
+ throws IOException {
MessageHandler.logln("rendering areas to XML");
this.writer = new PrintWriter(outputStream);
this.writer.write( "<?xml version=\"1.0\"?>\n<!-- produced by " +
this.producer + " -->\n");
writeStartTag("<AreaTree>");
}
-
+
/**
Default stop renderer method. This would
normally be overridden. (mark-fop@inomial.com).
*/
public void stopRenderer(OutputStream outputStream)
- throws IOException
- {
+ throws IOException {
writeEndTag("</AreaTree>");
this.writer.flush();
MessageHandler.errorln("written out XML");
- }
+ }
}
public TestConverter() {}
+
public void setOutputPDF(boolean pdf) {
outputPDF = pdf;
}
testsuite.getAttributes().getNamedItem("profile").getNodeValue();
// System.out.println("testing test suite:" + profile);
}
+
NodeList testcases = testsuite.getChildNodes();
for (int count = 0; count < testcases.getLength(); count++) {
Node testcase = testcases.item(count);
tcase.getAttributes().getNamedItem("profile").getNodeValue();
// System.out.println("testing profile:" + profile);
}
+
NodeList cases = tcase.getChildNodes();
for (int count = 0; count < cases.getLength(); count++) {
Node node = cases.item(count);
} else if (nodename.equals("test")) {
runTest(tcase, node);
} else if (nodename.equals("result")) {}
+
}
}
} else {
inputHandler = new XSLTInputHandler(xmlFile,
new File(baseDir + "/"
- + xsl));
+ + xsl));
}
XMLReader parser = inputHandler.getParser();
rendererOptions.put("fineDetail", new Boolean(false));
driver.getRenderer().setOptions(rendererOptions);
driver.getRenderer().setProducer("Testsuite Converter");
-
+
String outname = xmlFile.getName();
if (outname.endsWith(".xml")) {
outname = outname.substring(0, outname.length() - 4);
}
driver.setOutputStream(new FileOutputStream(new File(destdir,
- outname + (outputPDF ? ".pdf" : ".at.xml"))));
+ outname + (outputPDF ? ".pdf" : ".at.xml"))));
// System.out.println("ddir:" + destdir + " on:" + outname + ".pdf");
driver.render(parser, inputHandler.getInputSource());
}
}
} catch (Exception e) {}
+
return false;
}