From 13d6dc3a6a5e8bd3c17997351a0e6f087eb301a2 Mon Sep 17 00:00:00 2001 From: tknall Date: Tue, 25 Nov 2008 12:04:30 +0000 Subject: Removing itext from source. git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@302 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../text/pdf/events/FieldPositioningEvents.java | 186 ---------- .../com/lowagie/text/pdf/events/IndexEvents.java | 401 --------------------- .../text/pdf/events/PdfPCellEventForwarder.java | 91 ----- .../text/pdf/events/PdfPTableEventForwarder.java | 90 ----- .../text/pdf/events/PdfPageEventForwarder.java | 312 ---------------- 5 files changed, 1080 deletions(-) delete mode 100644 src/main/java/com/lowagie/text/pdf/events/FieldPositioningEvents.java delete mode 100644 src/main/java/com/lowagie/text/pdf/events/IndexEvents.java delete mode 100644 src/main/java/com/lowagie/text/pdf/events/PdfPCellEventForwarder.java delete mode 100644 src/main/java/com/lowagie/text/pdf/events/PdfPTableEventForwarder.java delete mode 100644 src/main/java/com/lowagie/text/pdf/events/PdfPageEventForwarder.java (limited to 'src/main/java/com/lowagie/text/pdf/events') diff --git a/src/main/java/com/lowagie/text/pdf/events/FieldPositioningEvents.java b/src/main/java/com/lowagie/text/pdf/events/FieldPositioningEvents.java deleted file mode 100644 index 144ebcc..0000000 --- a/src/main/java/com/lowagie/text/pdf/events/FieldPositioningEvents.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright 2005 by Bruno Lowagie - * - * The contents of this file are subject to the Mozilla Public License Version 1.1 - * (the "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the License. - * - * The Original Code is 'iText, a free JAVA-PDF library'. - * - * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by - * the Initial Developer are Copyright (C) 1999-2005 by Bruno Lowagie. - * All Rights Reserved. - * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer - * are Copyright (C) 2000-2005 by Paulo Soares. All Rights Reserved. - * - * Contributor(s): all the names of the contributors are added in the source code - * where applicable. - * - * Alternatively, the contents of this file may be used under the terms of the - * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the - * provisions of LGPL are applicable instead of those above. If you wish to - * allow use of your version of this file only under the terms of the LGPL - * License and not to allow others to use your version of this file under - * the MPL, indicate your decision by deleting the provisions above and - * replace them with the notice and other provisions required by the LGPL. - * If you do not delete the provisions above, a recipient may use your version - * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the MPL as stated above or under the terms of the GNU - * Library General Public License as published by the Free Software Foundation; - * either version 2 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more - * details. - * - * If you didn't download this code from the following link, you should check if - * you aren't using an obsolete version: - * http://www.lowagie.com/iText/ - */ -package com.lowagie.text.pdf.events; - -import java.io.IOException; -import java.util.HashMap; - -import com.lowagie.text.Document; -import com.lowagie.text.DocumentException; -import com.lowagie.text.ExceptionConverter; -import com.lowagie.text.Rectangle; -import com.lowagie.text.pdf.PdfContentByte; -import com.lowagie.text.pdf.PdfFormField; -import com.lowagie.text.pdf.PdfName; -import com.lowagie.text.pdf.PdfPCell; -import com.lowagie.text.pdf.PdfPCellEvent; -import com.lowagie.text.pdf.PdfPageEventHelper; -import com.lowagie.text.pdf.PdfRectangle; -import com.lowagie.text.pdf.PdfWriter; -import com.lowagie.text.pdf.TextField; - -/** - * Class for an index. - * - * @author Michael Niedermair - */ -public class FieldPositioningEvents extends PdfPageEventHelper implements PdfPCellEvent { - - /** - * Keeps a map with fields that are to be positioned in inGenericTag. - */ - protected HashMap genericChunkFields = new HashMap(); - - /** - * Keeps the form field that is to be positioned in a cellLayout event. - */ - protected PdfFormField cellField = null; - - /** - * The PdfWriter to use when a field has to added in a cell event. - */ - protected PdfWriter fieldWriter = null; - /** - * The PdfFormField that is the parent of the field added in a cell event. - */ - protected PdfFormField parent = null; - - /** Creates a new event. This constructor will be used if you need to position fields with Chunk objects. */ - public FieldPositioningEvents() {} - - /** Some extra padding that will be taken into account when defining the widget. */ - public float padding; - - /** - * Add a PdfFormField that has to be tied to a generic Chunk. - */ - public void addField(String text, PdfFormField field) { - genericChunkFields.put(text, field); - } - - /** Creates a new event. This constructor will be used if you need to position fields with a Cell Event. */ - public FieldPositioningEvents(PdfWriter writer, PdfFormField field) { - this.cellField = field; - this.fieldWriter = writer; - } - - /** Creates a new event. This constructor will be used if you need to position fields with a Cell Event. */ - public FieldPositioningEvents(PdfFormField parent, PdfFormField field) { - this.cellField = field; - this.parent = parent; - } - - /** Creates a new event. This constructor will be used if you need to position fields with a Cell Event. - * @throws DocumentException - * @throws IOException*/ - public FieldPositioningEvents(PdfWriter writer, String text) throws IOException, DocumentException { - this.fieldWriter = writer; - TextField tf = new TextField(writer, new Rectangle(0, 0), text); - tf.setFontSize(14); - cellField = tf.getTextField(); - } - - /** Creates a new event. This constructor will be used if you need to position fields with a Cell Event. - * @throws DocumentException - * @throws IOException*/ - public FieldPositioningEvents(PdfWriter writer, PdfFormField parent, String text) throws IOException, DocumentException { - this.parent = parent; - TextField tf = new TextField(writer, new Rectangle(0, 0), text); - tf.setFontSize(14); - cellField = tf.getTextField(); - } - - /** - * @param padding The padding to set. - */ - public void setPadding(float padding) { - this.padding = padding; - } - - /** - * @param parent The parent to set. - */ - public void setParent(PdfFormField parent) { - this.parent = parent; - } - /** - * @see com.lowagie.text.pdf.PdfPageEvent#onGenericTag(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document, com.lowagie.text.Rectangle, java.lang.String) - */ - public void onGenericTag(PdfWriter writer, Document document, - Rectangle rect, String text) { - rect.setBottom(rect.bottom() - 3); - PdfFormField field = (PdfFormField) genericChunkFields.get(text); - if (field == null) { - TextField tf = new TextField(writer, new Rectangle(rect.left(padding), rect.bottom(padding), rect.right(padding), rect.top(padding)), text); - tf.setFontSize(14); - try { - field = tf.getTextField(); - } catch (Exception e) { - throw new ExceptionConverter(e); - } - } - else { - field.put(PdfName.RECT, new PdfRectangle(rect.left(padding), rect.bottom(padding), rect.right(padding), rect.top(padding))); - } - if (parent == null) - writer.addAnnotation(field); - else - parent.addKid(field); - } - - /** - * @see com.lowagie.text.pdf.PdfPCellEvent#cellLayout(com.lowagie.text.pdf.PdfPCell, com.lowagie.text.Rectangle, com.lowagie.text.pdf.PdfContentByte[]) - */ - public void cellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] canvases) { - if (cellField == null || (fieldWriter == null && parent == null)) throw new ExceptionConverter(new IllegalArgumentException("You have used the wrong constructor for this FieldPositioningEvents class.")); - cellField.put(PdfName.RECT, new PdfRectangle(rect.left(padding), rect.bottom(padding), rect.right(padding), rect.top(padding))); - if (parent == null) - fieldWriter.addAnnotation(cellField); - else - parent.addKid(cellField); - } -} \ No newline at end of file diff --git a/src/main/java/com/lowagie/text/pdf/events/IndexEvents.java b/src/main/java/com/lowagie/text/pdf/events/IndexEvents.java deleted file mode 100644 index 13925a5..0000000 --- a/src/main/java/com/lowagie/text/pdf/events/IndexEvents.java +++ /dev/null @@ -1,401 +0,0 @@ -/* - * Copyright 2005 by Michael Niedermair. - * - * The contents of this file are subject to the Mozilla Public License Version 1.1 - * (the "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the License. - * - * The Original Code is 'iText, a free JAVA-PDF library'. - * - * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by - * the Initial Developer are Copyright (C) 1999-2005 by Bruno Lowagie. - * All Rights Reserved. - * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer - * are Copyright (C) 2000-2005 by Paulo Soares. All Rights Reserved. - * - * Contributor(s): all the names of the contributors are added in the source code - * where applicable. - * - * Alternatively, the contents of this file may be used under the terms of the - * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the - * provisions of LGPL are applicable instead of those above. If you wish to - * allow use of your version of this file only under the terms of the LGPL - * License and not to allow others to use your version of this file under - * the MPL, indicate your decision by deleting the provisions above and - * replace them with the notice and other provisions required by the LGPL. - * If you do not delete the provisions above, a recipient may use your version - * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the MPL as stated above or under the terms of the GNU - * Library General Public License as published by the Free Software Foundation; - * either version 2 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more - * details. - * - * If you didn't download this code from the following link, you should check if - * you aren't using an obsolete version: - * http://www.lowagie.com/iText/ - */ -package com.lowagie.text.pdf.events; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import com.lowagie.text.Chunk; -import com.lowagie.text.Document; -import com.lowagie.text.Rectangle; -import com.lowagie.text.pdf.PdfPageEventHelper; -import com.lowagie.text.pdf.PdfWriter; - -/** - * Class for an index. - * - * @author Michael Niedermair - */ -public class IndexEvents extends PdfPageEventHelper { - - /** - * keeps the indextag with the pagenumber - */ - private Map indextag = new TreeMap(); - - /** - * All the text that is passed to this event, gets registered in the indexentry. - * - * @see com.lowagie.text.pdf.PdfPageEventHelper#onGenericTag( - * com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document, - * com.lowagie.text.Rectangle, java.lang.String) - */ - public void onGenericTag(PdfWriter writer, Document document, - Rectangle rect, String text) { - indextag.put(text, new Integer(writer.getPageNumber())); - } - - // -------------------------------------------------------------------- - /** - * indexcounter - */ - private long indexcounter = 0; - - /** - * the list for the index entry - */ - private List indexentry = new ArrayList(); - - /** - * Create an index entry. - * - * @param text The text for the Chunk. - * @param in1 The first level. - * @param in2 The second level. - * @param in3 The third level. - * @return Returns the Chunk. - */ - public Chunk create(final String text, final String in1, final String in2, - final String in3) { - - Chunk chunk = new Chunk(text); - String tag = "idx_" + String.valueOf(indexcounter++); - chunk.setGenericTag(tag); - chunk.setLocalDestination(tag); - Entry entry = new Entry(in1, in2, in3, tag); - indexentry.add(entry); - return chunk; - } - - /** - * Create an index entry. - * - * @param text The text for the Chunk. - * @param in1 The first level. - * @return Returns the Chunk. - */ - public Chunk create(final String text, final String in1) { - return create(text, in1, "", ""); - } - - /** - * Create an index entry. - * - * @param text The text for the Chunk. - * @param in1 The first level. - * @param in2 The second level. - * @return Returns the Chunk. - */ - public Chunk create(final String text, final String in1, final String in2) { - return create(text, in1, in2, ""); - } - - /** - * Create an index entry. - * - * @param text The text. - * @param in1 The first level. - * @param in2 The second level. - * @param in3 The third level. - */ - public void create(final Chunk text, final String in1, final String in2, - final String in3) { - - String tag = "idx_" + String.valueOf(indexcounter++); - text.setGenericTag(tag); - text.setLocalDestination(tag); - Entry entry = new Entry(in1, in2, in3, tag); - indexentry.add(entry); - } - - /** - * Create an index entry. - * - * @param text The text. - * @param in1 The first level. - */ - public void create(final Chunk text, final String in1) { - create(text, in1, "", ""); - } - - /** - * Create an index entry. - * - * @param text The text. - * @param in1 The first level. - * @param in2 The second level. - */ - public void create(final Chunk text, final String in1, final String in2) { - create(text, in1, in2, ""); - } - - /** - * Comparator for sorting the index - */ - private Comparator comparator = new Comparator() { - - public int compare(Object arg0, Object arg1) { - Entry en1 = (Entry) arg0; - Entry en2 = (Entry) arg1; - - int rt = 0; - if (en1.getIn1() != null && en2.getIn1() != null) { - if ((rt = en1.getIn1().compareToIgnoreCase(en2.getIn1())) == 0) { - // in1 equals - if (en1.getIn2() != null && en2.getIn2() != null) { - if ((rt = en1.getIn2() - .compareToIgnoreCase(en2.getIn2())) == 0) { - // in2 equals - if (en1.getIn3() != null && en2.getIn3() != null) { - rt = en1.getIn3().compareToIgnoreCase( - en2.getIn3()); - } - } - } - } - } - return rt; - } - }; - - /** - * Set the comparator. - * @param aComparator The comparator to set. - */ - public void setComparator(Comparator aComparator) { - comparator = aComparator; - } - - /** - * Returns the sorted list with the entries and the collected page numbers. - * @return Returns the sorted list with the entries and teh collected page numbers. - */ - public List getSortedEntries() { - - Map grouped = new HashMap(); - - for (int i = 0; i < indexentry.size(); i++) { - Entry e = (Entry) indexentry.get(i); - String key = e.getKey(); - - Entry master = (Entry) grouped.get(key); - if (master != null) { - master.addPageNumberAndTag(e.getPageNumber(), e.getTag()); - } else { - e.addPageNumberAndTag(e.getPageNumber(), e.getTag()); - grouped.put(key, e); - } - } - - // copy to a list and sort it - List sorted = new ArrayList(grouped.size()); - Iterator it = grouped.keySet().iterator(); - while (it.hasNext()) { - String key = (String) it.next(); - Entry e = (Entry) grouped.get(key); - sorted.add(e); - } - Collections.sort(sorted, comparator); - return sorted; - } - - // -------------------------------------------------------------------- - /** - * Class for an index entry. - *

- * In the first step, only in1, in2,in3 and tag are used. - * After the collections of the index entries, pagenumbers are used. - *

- */ - public class Entry { - - /** - * first level - */ - private String in1; - - /** - * second level - */ - private String in2; - - /** - * third level - */ - private String in3; - - /** - * the tag - */ - private String tag; - - /** - * the lsit of all page numbers. - */ - private List pagenumbers = new ArrayList(); - - /** - * the lsit of all tags. - */ - private List tags = new ArrayList(); - - /** - * Create a new object. - * @param aIn1 The first level. - * @param aIn2 The second level. - * @param aIn3 The third level. - * @param aTag The tag. - */ - public Entry(final String aIn1, final String aIn2, final String aIn3, - final String aTag) { - in1 = aIn1; - in2 = aIn2; - in3 = aIn3; - tag = aTag; - } - - /** - * Returns the in1. - * @return Returns the in1. - */ - public String getIn1() { - return in1; - } - - /** - * Returns the in2. - * @return Returns the in2. - */ - public String getIn2() { - return in2; - } - - /** - * Returns the in3. - * @return Returns the in3. - */ - public String getIn3() { - return in3; - } - - /** - * Returns the tag. - * @return Returns the tag. - */ - public String getTag() { - return tag; - } - - /** - * Returns the pagenumer for this entry. - * @return Returns the pagenumer for this entry. - */ - public int getPageNumber() { - int rt = -1; - Integer i = (Integer) indextag.get(tag); - if (i != null) { - rt = i.intValue(); - } - return rt; - } - - /** - * Add a pagenumber. - * @param number The page number. - * @param tag - */ - public void addPageNumberAndTag(final int number, final String tag) { - pagenumbers.add(new Integer(number)); - tags.add(tag); - } - - /** - * Returns the key for the map-entry. - * @return Returns the key for the map-entry. - */ - public String getKey() { - return in1 + "!" + in2 + "!" + in3; - } - - /** - * Returns the pagenumbers. - * @return Returns the pagenumbers. - */ - public List getPagenumbers() { - return pagenumbers; - } - - /** - * Returns the tags. - * @return Returns the tags. - */ - public List getTags() { - return tags; - } - - /** - * print the entry (only for test) - * @return the toString implementation of the entry - */ - public String toString() { - StringBuffer buf = new StringBuffer(); - buf.append(in1).append(" "); - buf.append(in2).append(" "); - buf.append(in3).append(" "); - for (int i = 0; i < pagenumbers.size(); i++) { - buf.append(pagenumbers.get(i)).append(" "); - } - return buf.toString(); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/lowagie/text/pdf/events/PdfPCellEventForwarder.java b/src/main/java/com/lowagie/text/pdf/events/PdfPCellEventForwarder.java deleted file mode 100644 index 080f380..0000000 --- a/src/main/java/com/lowagie/text/pdf/events/PdfPCellEventForwarder.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * $Id: PdfPCellEventForwarder.java,v 1.1 2005/10/27 15:57:53 blowagie Exp $ - * $Name: $ - * - * Copyright 2005 Bruno Lowagie - * - * The contents of this file are subject to the Mozilla Public License Version 1.1 - * (the "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the License. - * - * The Original Code is 'iText, a free JAVA-PDF library'. - * - * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by - * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie. - * All Rights Reserved. - * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer - * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved. - * - * Contributor(s): all the names of the contributors are added in the source code - * where applicable. - * - * Alternatively, the contents of this file may be used under the terms of the - * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the - * provisions of LGPL are applicable instead of those above. If you wish to - * allow use of your version of this file only under the terms of the LGPL - * License and not to allow others to use your version of this file under - * the MPL, indicate your decision by deleting the provisions above and - * replace them with the notice and other provisions required by the LGPL. - * If you do not delete the provisions above, a recipient may use your version - * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the MPL as stated above or under the terms of the GNU - * Library General Public License as published by the Free Software Foundation; - * either version 2 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more - * details. - * - * If you didn't download this code from the following link, you should check if - * you aren't using an obsolete version: - * http://www.lowagie.com/iText/ - */ - -package com.lowagie.text.pdf.events; - -import java.util.ArrayList; -import java.util.Iterator; - -import com.lowagie.text.Rectangle; -import com.lowagie.text.pdf.PdfContentByte; -import com.lowagie.text.pdf.PdfPCell; -import com.lowagie.text.pdf.PdfPCellEvent; - -/** - * If you want to add more than one event to a cell, - * you have to construct a PdfPCellEventForwarder, add the - * different events to this object and add the forwarder to - * the PdfPCell. - */ - -public class PdfPCellEventForwarder implements PdfPCellEvent { - - /** ArrayList containing all the PageEvents that have to be executed. */ - protected ArrayList events = new ArrayList(); - - /** - * Add a page event to the forwarder. - * @param event an event that has to be added to the forwarder. - */ - public void addCellEvent(PdfPCellEvent event) { - events.add(event); - } - - /** - * @see com.lowagie.text.pdf.PdfPCellEvent#cellLayout(com.lowagie.text.pdf.PdfPCell, com.lowagie.text.Rectangle, com.lowagie.text.pdf.PdfContentByte[]) - */ - public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) { - PdfPCellEvent event; - for (Iterator i = events.iterator(); i.hasNext(); ) { - event = (PdfPCellEvent)i.next(); - event.cellLayout(cell, position, canvases); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/lowagie/text/pdf/events/PdfPTableEventForwarder.java b/src/main/java/com/lowagie/text/pdf/events/PdfPTableEventForwarder.java deleted file mode 100644 index 8645385..0000000 --- a/src/main/java/com/lowagie/text/pdf/events/PdfPTableEventForwarder.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * $Id: PdfPTableEventForwarder.java,v 1.1 2005/10/27 15:57:52 blowagie Exp $ - * $Name: $ - * - * Copyright 2005 Bruno Lowagie - * - * The contents of this file are subject to the Mozilla Public License Version 1.1 - * (the "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the License. - * - * The Original Code is 'iText, a free JAVA-PDF library'. - * - * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by - * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie. - * All Rights Reserved. - * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer - * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved. - * - * Contributor(s): all the names of the contributors are added in the source code - * where applicable. - * - * Alternatively, the contents of this file may be used under the terms of the - * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the - * provisions of LGPL are applicable instead of those above. If you wish to - * allow use of your version of this file only under the terms of the LGPL - * License and not to allow others to use your version of this file under - * the MPL, indicate your decision by deleting the provisions above and - * replace them with the notice and other provisions required by the LGPL. - * If you do not delete the provisions above, a recipient may use your version - * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the MPL as stated above or under the terms of the GNU - * Library General Public License as published by the Free Software Foundation; - * either version 2 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more - * details. - * - * If you didn't download this code from the following link, you should check if - * you aren't using an obsolete version: - * http://www.lowagie.com/iText/ - */ - -package com.lowagie.text.pdf.events; - -import java.util.ArrayList; -import java.util.Iterator; - -import com.lowagie.text.pdf.PdfContentByte; -import com.lowagie.text.pdf.PdfPTable; -import com.lowagie.text.pdf.PdfPTableEvent; - -/** - * If you want to add more than one page event to a PdfPTable, - * you have to construct a PdfPTableEventForwarder, add the - * different events to this object and add the forwarder to - * the PdfWriter. - */ - -public class PdfPTableEventForwarder implements PdfPTableEvent { - - /** ArrayList containing all the PageEvents that have to be executed. */ - protected ArrayList events = new ArrayList(); - - /** - * Add a page event to the forwarder. - * @param event an event that has to be added to the forwarder. - */ - public void addTableEvent(PdfPTableEvent event) { - events.add(event); - } - - /** - * @see com.lowagie.text.pdf.PdfPTableEvent#tableLayout(com.lowagie.text.pdf.PdfPTable, float[][], float[], int, int, com.lowagie.text.pdf.PdfContentByte[]) - */ - public void tableLayout(PdfPTable table, float[][] widths, float[] heights, int headerRows, int rowStart, PdfContentByte[] canvases) { - PdfPTableEvent event; - for (Iterator i = events.iterator(); i.hasNext(); ) { - event = (PdfPTableEvent)i.next(); - event.tableLayout(table, widths, heights, headerRows, rowStart, canvases); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/lowagie/text/pdf/events/PdfPageEventForwarder.java b/src/main/java/com/lowagie/text/pdf/events/PdfPageEventForwarder.java deleted file mode 100644 index 58bf3c2..0000000 --- a/src/main/java/com/lowagie/text/pdf/events/PdfPageEventForwarder.java +++ /dev/null @@ -1,312 +0,0 @@ -/* - * $Id: PdfPageEventForwarder.java,v 1.1 2005/10/07 07:14:18 blowagie Exp $ - * $Name: $ - * - * Copyright 2005 Bruno Lowagie - * - * The contents of this file are subject to the Mozilla Public License Version 1.1 - * (the "License"); you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the License. - * - * The Original Code is 'iText, a free JAVA-PDF library'. - * - * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by - * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie. - * All Rights Reserved. - * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer - * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved. - * - * Contributor(s): all the names of the contributors are added in the source code - * where applicable. - * - * Alternatively, the contents of this file may be used under the terms of the - * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the - * provisions of LGPL are applicable instead of those above. If you wish to - * allow use of your version of this file only under the terms of the LGPL - * License and not to allow others to use your version of this file under - * the MPL, indicate your decision by deleting the provisions above and - * replace them with the notice and other provisions required by the LGPL. - * If you do not delete the provisions above, a recipient may use your version - * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the MPL as stated above or under the terms of the GNU - * Library General Public License as published by the Free Software Foundation; - * either version 2 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more - * details. - * - * If you didn't download this code from the following link, you should check if - * you aren't using an obsolete version: - * http://www.lowagie.com/iText/ - */ - -package com.lowagie.text.pdf.events; - -import java.util.ArrayList; -import java.util.Iterator; - -import com.lowagie.text.Document; -import com.lowagie.text.Rectangle; -import com.lowagie.text.Paragraph; -import com.lowagie.text.pdf.PdfPageEvent; -import com.lowagie.text.pdf.PdfWriter; - -/** - * If you want to add more than one page event to a PdfWriter, - * you have to construct a PdfPageEventForwarder, add the - * different events to this object and add the forwarder to - * the PdfWriter. - */ - -public class PdfPageEventForwarder implements PdfPageEvent { - - /** ArrayList containing all the PageEvents that have to be executed. */ - protected ArrayList events = new ArrayList(); - - /** - * Add a page event to the forwarder. - * @param event an event that has to be added to the forwarder. - */ - public void addPageEvent(PdfPageEvent event) { - events.add(event); - } - - /** - * Called when the document is opened. - * - * @param writer - * the PdfWriter for this document - * @param document - * the document - */ - public void onOpenDocument(PdfWriter writer, Document document) { - PdfPageEvent event; - for (Iterator i = events.iterator(); i.hasNext(); ) { - event = (PdfPageEvent)i.next(); - event.onOpenDocument(writer, document); - } - } - - /** - * Called when a page is initialized. - *

- * Note that if even if a page is not written this method is still called. - * It is preferable to use onEndPage to avoid infinite loops. - * - * @param writer - * the PdfWriter for this document - * @param document - * the document - */ - public void onStartPage(PdfWriter writer, Document document) { - PdfPageEvent event; - for (Iterator i = events.iterator(); i.hasNext(); ) { - event = (PdfPageEvent)i.next(); - event.onStartPage(writer, document); - } - } - - /** - * Called when a page is finished, just before being written to the - * document. - * - * @param writer - * the PdfWriter for this document - * @param document - * the document - */ - public void onEndPage(PdfWriter writer, Document document) { - PdfPageEvent event; - for (Iterator i = events.iterator(); i.hasNext(); ) { - event = (PdfPageEvent)i.next(); - event.onEndPage(writer, document); - } - } - - /** - * Called when the document is closed. - *

- * Note that this method is called with the page number equal to the last - * page plus one. - * - * @param writer - * the PdfWriter for this document - * @param document - * the document - */ - public void onCloseDocument(PdfWriter writer, Document document) { - PdfPageEvent event; - for (Iterator i = events.iterator(); i.hasNext(); ) { - event = (PdfPageEvent)i.next(); - event.onCloseDocument(writer, document); - } - } - - /** - * Called when a Paragraph is written. - *

- * paragraphPosition will hold the height at which the - * paragraph will be written to. This is useful to insert bookmarks with - * more control. - * - * @param writer - * the PdfWriter for this document - * @param document - * the document - * @param paragraphPosition - * the position the paragraph will be written to - */ - public void onParagraph(PdfWriter writer, Document document, - float paragraphPosition) { - PdfPageEvent event; - for (Iterator i = events.iterator(); i.hasNext(); ) { - event = (PdfPageEvent)i.next(); - event.onParagraph(writer, document, paragraphPosition); - } - } - - /** - * Called when a Paragraph is written. - *

- * paragraphPosition will hold the height of the end of the - * paragraph. - * - * @param writer - * the PdfWriter for this document - * @param document - * the document - * @param paragraphPosition - * the position of the end of the paragraph - */ - public void onParagraphEnd(PdfWriter writer, Document document, - float paragraphPosition) { - PdfPageEvent event; - for (Iterator i = events.iterator(); i.hasNext(); ) { - event = (PdfPageEvent)i.next(); - event.onParagraphEnd(writer, document, paragraphPosition); - } - } - - /** - * Called when a Chapter is written. - *

- * position will hold the height at which the chapter will be - * written to. - * - * @param writer - * the PdfWriter for this document - * @param document - * the document - * @param paragraphPosition - * the position the chapter will be written to - * @param title - * the title of the Chapter - */ - public void onChapter(PdfWriter writer, Document document, - float paragraphPosition, Paragraph title) { - PdfPageEvent event; - for (Iterator i = events.iterator(); i.hasNext(); ) { - event = (PdfPageEvent)i.next(); - event.onChapter(writer, document, paragraphPosition, title); - } - } - - /** - * Called when the end of a Chapter is reached. - *

- * position will hold the height of the end of the chapter. - * - * @param writer - * the PdfWriter for this document - * @param document - * the document - * @param position - * the position of the end of the chapter. - */ - public void onChapterEnd(PdfWriter writer, Document document, float position) { - PdfPageEvent event; - for (Iterator i = events.iterator(); i.hasNext(); ) { - event = (PdfPageEvent)i.next(); - event.onChapterEnd(writer, document, position); - } - } - - /** - * Called when a Section is written. - *

- * position will hold the height at which the section will be - * written to. - * - * @param writer - * the PdfWriter for this document - * @param document - * the document - * @param paragraphPosition - * the position the section will be written to - * @param depth - * the number depth of the Section - * @param title - * the title of the section - */ - public void onSection(PdfWriter writer, Document document, - float paragraphPosition, int depth, Paragraph title) { - PdfPageEvent event; - for (Iterator i = events.iterator(); i.hasNext(); ) { - event = (PdfPageEvent)i.next(); - event.onSection(writer, document, paragraphPosition, depth, title); - } - } - - /** - * Called when the end of a Section is reached. - *

- * position will hold the height of the section end. - * - * @param writer - * the PdfWriter for this document - * @param document - * the document - * @param position - * the position of the end of the section - */ - public void onSectionEnd(PdfWriter writer, Document document, float position) { - PdfPageEvent event; - for (Iterator i = events.iterator(); i.hasNext(); ) { - event = (PdfPageEvent)i.next(); - event.onSectionEnd(writer, document, position); - } - } - - /** - * Called when a Chunk with a generic tag is written. - *

- * It is usefull to pinpoint the Chunk location to generate - * bookmarks, for example. - * - * @param writer - * the PdfWriter for this document - * @param document - * the document - * @param rect - * the Rectangle containing the Chunk - * - * @param text - * the text of the tag - */ - public void onGenericTag(PdfWriter writer, Document document, - Rectangle rect, String text) { - PdfPageEvent event; - for (Iterator i = events.iterator(); i.hasNext(); ) { - event = (PdfPageEvent)i.next(); - event.onGenericTag(writer, document, rect, text); - } - } -} \ No newline at end of file -- cgit v1.2.3