ASF Bugzilla – Attachment 26712 Details for
Bug 50852
[PATCH] Improve generation of PDFs with accessibility information
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch 12/20
0012-Add-support-for-lazy-object-number-assignment.patch (text/plain), 3.57 KB, created by
Martin K
on 2011-03-02 07:04:43 UTC
(
hide
)
Description:
Patch 12/20
Filename:
MIME Type:
Creator:
Martin K
Created:
2011-03-02 07:04:43 UTC
Size:
3.57 KB
patch
obsolete
>Subject: [PATCH 12/20] Add support for lazy object number assignment > >--- > src/java/org/apache/fop/pdf/PDFDocument.java | 34 +++++++++++++++++++++++++- > src/java/org/apache/fop/pdf/PDFObject.java | 14 ++++++++++- > 2 files changed, 46 insertions(+), 2 deletions(-) > >diff --git a/src/java/org/apache/fop/pdf/PDFDocument.java b/src/java/org/apache/fop/pdf/PDFDocument.java >index e97e649..697af11 100644 >--- a/src/java/org/apache/fop/pdf/PDFDocument.java >+++ b/src/java/org/apache/fop/pdf/PDFDocument.java >@@ -404,7 +404,7 @@ public class PDFDocument { > if (obj == null) { > throw new NullPointerException("obj must not be null"); > } >- if (obj.hasObjectNumber()) { >+ if (!obj.hasLazyObjectNumber() && obj.hasObjectNumber()) { > throw new IllegalStateException( > "Error registering a PDFObject: " > + "PDFObject already has an object number"); >@@ -424,6 +424,35 @@ public class PDFDocument { > } > > /** >+ * Assigns the {@link PDFObject} an object number when it is first used, >+ * and sets the parent of the {@link PDFObject} to this document. >+ * >+ * @param obj {@link PDFObject} to assign a number to >+ */ >+ public void lazyAssignObjectNumber(PDFObject obj) { >+ if (obj == null) { >+ throw new NullPointerException("obj must not be null"); >+ } >+ if (obj.hasObjectNumber()) { >+ throw new IllegalStateException( >+ "Error registering a PDFObject: " >+ + "PDFObject already has an object number"); >+ } >+ PDFDocument currentParent = obj.getDocument(); >+ if (currentParent != null && currentParent != this) { >+ throw new IllegalStateException( >+ "Error registering a PDFObject: " >+ + "PDFObject already has a parent PDFDocument"); >+ } >+ >+ obj.setObjectNumber(-1); >+ >+ if (currentParent == null) { >+ obj.setDocument(this); >+ } >+ } >+ >+ /** > * Adds a {@link PDFObject} to this document. > * The object <em>MUST</em> have an object number assigned. > * >@@ -1107,6 +1136,9 @@ public class PDFDocument { > throw new IOException("PDF file too large. PDF cannot grow beyond approx. 9.3GB."); > } > >+ if (s.equals("0")) >+ throw new IOException("PDF object "+(count+1)+" with position 0"); >+ > /* contruct xref entry for object */ > loc = padding.substring(s.length()) + s; > >diff --git a/src/java/org/apache/fop/pdf/PDFObject.java b/src/java/org/apache/fop/pdf/PDFObject.java >index 897c2f8..ef2f3e1 100644 >--- a/src/java/org/apache/fop/pdf/PDFObject.java >+++ b/src/java/org/apache/fop/pdf/PDFObject.java >@@ -69,6 +69,9 @@ public abstract class PDFObject implements PDFWritable { > if (this.objnum == 0) { > throw new IllegalStateException("Object has no number assigned: " + this.toString()); > } >+ if (this.objnum == -1) { >+ document.assignObjectNumber(this); >+ } > return this.objnum; > } > >@@ -93,7 +96,16 @@ public abstract class PDFObject implements PDFWritable { > * @return True if it has an object number > */ > public boolean hasObjectNumber() { >- return this.objnum > 0; >+ return this.objnum > 0 || this.objnum == -1; >+ } >+ >+ /** >+ * Indicates whether this PDFObject will be assigned an >+ * object number. >+ * @return True if it has an object number >+ */ >+ public boolean hasLazyObjectNumber() { >+ return this.objnum == -1; > } > > /** >-- >1.6.4.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 50852
:
26701
|
26702
|
26703
|
26704
|
26705
|
26706
|
26707
|
26708
|
26709
|
26710
|
26711
|
26712
|
26713
|
26714
|
26715
|
26716
|
26717
|
26718
|
26719
|
26720
|
27171
|
28824
|
28825
|
28826